handlez36
Forum Replies Created
-
Apologies for the late reply, but I found where the issue may be. Not sure if the plugin authors would define it as an issue, but there doesn’t seem to be a flag to indicate not to include tribe_events for post searches via API calls. There is a setting to not include them when you’re viewing the events outside of an Api context though (Admin_Helpers::instance()->is_post_type_screen( ‘post’ )), but not via an Api call.
In the following file “wp-content/plugins/the-events-calendar/src/Tribe/Query.php”, there are the following lines…
// Add Events to tag archives when not looking at the admin screen for posts.
if (
! $any_post_type
&& $query->is_tag
&& ! $is_event_query
&& ! Admin_Helpers::instance()->is_post_type_screen( ‘post’ )
) {
self::add_post_type_to_query( $query, TEC::POSTTYPE );
}
The API query I was using matched ALL of these conditions. I assume if this was to support hiding tribe_events specifically for Api access the Admin_Helpers instance should include a is_post_type_api_call() method or something, but it doesn’t look like one exists. So I just commented out the add_post_type_to_query call, and that seemed to work.
Forum: Plugins
In reply to: [The Events Calendar] tribe_events being inserted into WP_Query argsHi, 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, 30I 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!