Filter Recurring Events from Event Manager for WordPress Listings

At WordHerd we migrate a large volume of websites on a regular basis and in doing so, we often come across the need for an Events Calendar. We’ve used many over the years, but have really settled on Events Manager for WordPress because, unlike others we’ve tried, it is very reliable and never lets us down.

In a recent project we came across a unique scenario that we didn’t think the Events Manager was going to be able to handle, but lo and behold, it came through. The Events Listing page on this particular site separated the recurring events separate from the non-recurring events. The challenge was to fulfill this requirement while maintaining the filtering and pagination.

The documentation offers a lot of great resources, but the filters and hooks are left to the user to discover in the Events Manager for WordPress API repo. After some digging we were able to filter the sql conditions and ensure no recurring events were included in the final results.

function em_events_filter_recurrences($sql, $args) {
  $sql['recurrence'] = '(`recurrence` IS NULL)';
  $sql['recurring'] = '(`recurrence_id` IS NULL)';
  return $sql;

In the end, the resulting code was quite easy to write and leaves our development team desiring more event calendars in future migrations!