Tribe Events Query Recurring Events

Modern Tribe have a really nice calendar plugin. The basic plugin is pretty good for individual use but if you really want to get full functionality you need to go pro.

That being said I ran into an issue attempting to query some recurring events. I as trying to do a regular old meta query post and order by the “_EventStartDate” meta value.

This seemed like it was working at first and it was…but then I setup recurring events. Recurring events does not create new posts but rather updates the original post to include multiple dates. This means if you can get completely incorrect date orders for your events!

I ended up just having to write my own query which looked like this.

Of course you may not want to “SELECT *” and just get the ID, post_title and meta_value columns.

One last piece of advice is to make sure you are able to link to the correct event. If you just call the get_permalink($event->ID) you will get the link to the first event. You need to attach the event date to the url like so:

 

I hope this helps!