• Resolved maneshe

    (@maneshe)


    I am working on a plugin that will get the last 4 posts from my site. I have setup the following WP_Query to do this:

    $args = array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'posts_per_page' => 4,
    'orderby' => 'date',
    'order' => 'DESC',
    );
    $posts = new WP_Query($args);
    

    When that executes, I am seeing posts of type ‘tribe_events’ and ‘post’. I can see that somehow the ‘tribe_events’ post type is getting inserted into my SQL query as well.

    SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
    FROM wp_posts
    WHERE 1=1
    AND wp_posts.post_type IN ('post', 'tribe_events')
    AND ((wp_posts.post_status = 'publish'))
    ORDER BY wp_posts.post_date DESC
    LIMIT 0, 4

    How is the post type ‘tribe_events’ getting inserted into my custom query? I only see this happening on the front end of my site too. When I disabled The Events Calendar plugin, the issue went away. I tried different themes and this didn’t help either.

    The Events Calendar version 6.0.4
    Wordpress version 6.1.1

    • This topic was modified 2 years ago by maneshe.
Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support Darian

    (@d0153)

    Hi @maneshe,

    Thanks for reaching out.

    It seems the events are included in your main blog loop. To disable that, please ensure that “Include events in main blog loop” option is not checked from your Events > Settings page
    See- https://share.getcloudapp.com/NQu4E9Q1

    I hope that helps, and please let me know if you have further concerns.

    Thread Starter maneshe

    (@maneshe)

    Hi @d0153,

    That was it. Thank you very much!

    Plugin Support Darian

    (@d0153)

    Hi @maneshe,

    I’m glad that I was able to help you with this one. Thanks for letting me know.

    I am going to mark this ticket as solved. If you need assistance on another new topic, feel free to open a new thread.
    We’d be glad to help you out and assist you.

    Plugin Support Guga Alves

    (@gugaalves)

    Hi @maneshe,

    We’ve fixed that issue and now the query will work correctly even if the “Include events in main blog loop” option is enabled.

    Please update your Events Calendar plugin to version 6.0.6.1 to apply that fix to your site.

    Best Regards,

    Guga

    Hi, I have seen the same issue except when querying via the WP Rest API. This only seems to happen when using a tag or category (I assume any kind of taxonomy based query params). The query I am getting back is as follows:

    SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
    FROM wp_posts LEFT JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relationships.object_id)
    WHERE 1=1 AND (
    wp_term_relationships.term_taxonomy_id IN (18)
    ) AND wp_posts.post_type IN (‘tribe_events’, ‘post’) AND ((wp_posts.post_status = ‘publish’))
    GROUP BY wp_posts.ID
    ORDER BY wp_posts.post_date DESC
    LIMIT 0, 30

    I placed code to examine the SQL query in this file. …./wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php. I’ve also validated that the “Include events in main blog loop” was disabled. It’s actually always been disabled, so I don’t think there could be any caching issues related to still seeing it.

    Any help around how to not have tribe_events post_type automatically inserted for Rest API queries would be appreciated!

    Thank you!

    same issue as @handlez36

    on my website https://www.eugenioruberto.it, the custom query to show cause donation widget on footer, when I search for a tag, show me the last events, not cause donation as expected.

    normal footer: https://nimb.ws/Tv9d5o

    issue fotter (when tag searched ex: https://www.eugenioruberto.it/tag/papa-francesco/): https://nimb.ws/hUHpbD

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘tribe_events being inserted into WP_Query args’ is closed to new replies.