Rest post query with post_type = post automatically includes tribe_events type
-
Hi, I have seen an issue with querying WP via Rest API platform while including taxonomy parameters (categories, tags). These queries seem to bring back posts and tribe_events that share the tag. In my use case I only want posts for that taxonomy type. The query I see being run when I fire a request 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, 30I placed code to examine the SQL query in this file. …./wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php. Prior to the
“$query_result = $posts_query->query( $args )”
line running (and after the “apply_filters” call for “rest_{$this->post_type}_query”), I explicitly set $args[‘post_type’] = ‘post’; I would expect this to only pull posts, no tribe events.
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!
The topic ‘Rest post query with post_type = post automatically includes tribe_events type’ is closed to new replies.