Version 6.0.2 breaks custom end_date query
-
I’ve written a plugin that modifies the output of The Events Calendar’s RSS feeds. One setting in it allows the user to define a maximum number of dates to include in the feed, which works by using the
end_datequery parameter as defined here:https://theeventscalendar.com/knowledgebase/k/crafting-custom-event-queries/#date-params
This feature stopped working as of version 6.0.2, and I believe this is due to the new
Tribe__Events__Query::filter_and_order_by_datemethod, which adds a newtec_event_end_datemeta query. This meta query appears to be overriding the old, documentedend_datequery option.I was able to work around the issue by writing my own function that hooks onto the
tribe_events_parse_queryfilter with priority1001and appends my own end date logic to thetec_event_end_datemeta query, as such (using an$end_datevariable that I have already defined outside this conditional):if (isset($query->query['meta_query']['tec_event_end_date'])) { $meta_query = array( 'relation' => 'AND', $query->query['meta_query']['tec_event_end_date'], array( 'key' => '_EventEndDate', 'value' => $end_date, 'compare' => '<=', 'type' => 'DATETIME', ) ); $query->query_vars['meta_query']['tec_event_end_date'] = $meta_query; $query->query['meta_query'] = $query->query_vars['meta_query']; }But this is definitely not ideal, and much more complicated than the old way:
$query->set('end_date', $end_date);Is there something I’m missing? Does
end_datestill work, but I’m just approaching it incorrectly? Or am I right that this change to 6.0.2. is breaking it?
The topic ‘Version 6.0.2 breaks custom end_date query’ is closed to new replies.