分享这篇文章

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.

add_filter('em_events_build_sql_conditions','em_events_filter_recurrences',1,2);
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!

准备好迁移您的网站了吗?

首先进行免费的无义务网站评估。我们将对您的项目进行评估,推荐合适的平台,并为您提供明确的报价。

保证零数据丢失
完整 SEO 保留与重定向映射
准时且按预算交付
专业化的平台专家,而非泛泛的专家

请告诉我们您的网站信息

"*"*” 表示必填字段

此字段用于验证目的,不应更改。
姓名*