• 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_date query 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_date method, which adds a new tec_event_end_date meta query. This meta query appears to be overriding the old, documented end_date query option.

    I was able to work around the issue by writing my own function that hooks onto the tribe_events_parse_query filter with priority 1001 and appends my own end date logic to the tec_event_end_date meta query, as such (using an $end_date variable 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_date still work, but I’m just approaching it incorrectly? Or am I right that this change to 6.0.2. is breaking it?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support WilloftheD

    (@abzlevelup)

    Hi @room34, the end_date should still work. But I suspect that this has something to do with the recent updates where we fixed upcoming events, which were out of order.

    Let me reach out to our devs what’s the best way to go with this one. I’d get back to you whenever I hear from them.

    Best,
    Abz

    @abzlevelup Thanks… it did look to me like the new code that seems to be interfering with end_date is the same code you’re talking about. I didn’t see any indication that the logic for end_date was removed, but I think this new code is inadvertently overriding it.

    Thanks for investigating.

    Plugin Support WilloftheD

    (@abzlevelup)

    Hi @room34, it seems like this is related to CT1 implementation. Also, the KB is not updated, appreciate you sharing this with me. The best place to start is to follow this Dev Docs Guide here → https://docs.theeventscalendar.com/apis/custom-tables/events/#the-custom-tables-used-by-the-ct1-implementation.

    Let me know if that helps.

    Best,
    Abz

    Thanks… am I reading correctly that TEC is moving to storing events in a custom table instead of in wp_posts? If so, is the structure of the query object for these custom tables more-or-less identical to WP_Query?

    As part of my reverse engineering of this to get my RSS Enhancements plugin working again, I ended up switching my code from using pre_get_posts to using tribe_events_parse_query, so I’ll probably be OK, as long as the query object works the same as before. I’m just wondering if there are any other potential surprises waiting for me.

    Plugin Support WilloftheD

    (@abzlevelup)

    Hi @room34, moving forward we’d try to utilize more of the CT1. For now, it is okay since the query object does work. We’d be adding more details on our changelogs to avoid any surprises in the future. 🙂

    Have a great day.

    Best,
    Abz

    Plugin Support WilloftheD

    (@abzlevelup)

    Hey @room34, this thread has been inactive for a while, so we’re going to go ahead and mark it Resolved. Please feel free to open a new thread if any other questions come up, and we’d be happy to help.

    Cheers,
    Abz

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Version 6.0.2 breaks custom end_date query’ is closed to new replies.