• Hi,

    Recently one of my plugin’s user reported an issue that, the query for custom post type includes “the events calendar” events.

    The plugin does query like below. Note the “hello world” key set to the query to identify it.

    Expecting the query to have only “announcer” post type.

    Can we please check which pre_get_posts filter is modifying the query?

            $announcement_posts = get_posts(array(
                'post_type' => ANCR_POST_TYPE,
                'posts_per_page' => -1,
                'orderby' => 'menu_order',
                'order' => 'asc',
                'post_status' => 'publish',
                'hello' => 'world'
            ));
    function modify_announcements_query($query) {
        print_r($query);
    }
    add_action('pre_get_posts', 'modify_announcements_query', 1, 999);
    		WP_Query Object
    (
        [query] => Array
            (
                [numberposts] => 5
                [category] => 0
                [orderby] => menu_order
                [order] => asc
                [include] => Array
                    (
                    )
    
                [exclude] => Array
                    (
                    )
    
                [meta_key] => 
                [meta_value] => 
                [post_type] => Array
                    (
                        [0] => tribe_events
                        [1] => announcer
                    )
    
                [suppress_filters] => 1
                [posts_per_page] => -1
                [post_status] => publish
                [hello] => world
                [ignore_sticky_posts] => 1
                [no_found_rows] => 1
            )

    Thanks

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Darian

    (@d0153)

    Hi @vaakash

    Thank you for contacting us. Let me help you with this one.

    The issue you are experiencing seems to be related to the “Include events in main blog loop” option. You can locate this option by going to Events > Settings > General. Would you mind trying to uncheck this option to see if it resolves the issue?

    Additionally, you can try adding tribe_suppress_query_filters to your query to see if that helps.

    $announcement_posts = get_posts(array(
        'post_type' => ANCR_POST_TYPE,
        'posts_per_page' => -1,
        'orderby' => 'menu_order',
        'order' => 'asc',
        'post_status' => 'publish',
        'hello' => 'world',
        'tribe_suppress_query_filters' => true
    ));

    Let me know how it goes.

    Thread Starter vaakash

    (@vaakash)

    Hi @d0153,

    The “Include events in main blog loop” option is already “unchecked”.

    Also, setting “tribe_suppress_query_filters” would not be a possible solution since this is applies to any get_post() query regardless of any plugin or custom post type.

    You can reproduce the issue on your side by doing a get_posts() query for a custom post type in the wp_footer hook. The issue can be seen on <site>/events/tag/<even_tag_name>

    Thanks

    Plugin Support Darian

    (@d0153)

    Hi @vaakash

    Thank you for responding.

    I was able to replicate the problem on my testing site and have already informed the team. I will let you know as soon as I receive an update from them.

    Plugin Support Darian

    (@d0153)

    Hi @vaakash

    I’m reaching out to let you know that we’ve created an internal ticket to address the issue you reported, and we’ve included your case in it.

    Unfortunately, we don’t have an estimated time for when the issue will be resolved, but we’ll keep you updated as soon as a solution becomes available.

    Let me know if you have further questions or concerns.


    Internal Bug Ticket Reference: BTRIA-1925

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘get_posts() query is modified by the plugin’ is closed to new replies.