• Resolved erikjandelange

    (@erikjandelange)


    Hi there,

    I’m buiding custom plugins and saw you are using the pre_get_posts hook. This is a powerfull hook in linking the posts to the weburl.

    The way elementor is using it, can undo the changes that other plugins just made, like i’ve just encountered. I’m using the same hook (also without priority given) only my plugin is loaded before the element-plugin. Then your hook is fired and mine will be made undone. I’m also adding post_types to the query.

    In Line 365 of module.php of LandingPages you’re defining the defaults and your own CPT.

    To make it work better with other plugins, please change this.

    For example:
    $query_post_types = array_merge( $query->get('post_type'), [self::CPT] );

    In this way you only add your own post_type to the currently present post_types.
    Imho a prettier way to achieve the same result (without affecting other plugins).

    Cheers!
    Erik

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Overwriting other plugins pre_get_posts hooks’ is closed to new replies.