作者:翻版的袁城 | 来源:互联网 | 2023-10-15 18:44
本文由编程笔记#小编为大家整理,主要介绍了php 活动日历 - 获取下一个即将举行的特色活动相关的知识,希望对你有一定的参考价值。
/**
* The Events Calendar - Get the next upcoming Featured Event
*
* Notes:
* 1) Ignores all-day events.
* 2) For the date comparison, this code assumes each event is in
* the same timezone as your WordPress General Settings timezone.
*
* @link https://gist.github.com/cliffordp/1b8c808efa4256ebcef2d8805f069595
* @link https://theeventscalendar.com/support/forums/topic/pull-in-latest-featured-event/
* @link https://make.wordpress.org/core/2014/08/29/a-more-powerful-order-by-in-wordpress-4-0/
* @link https://theeventscalendar.com/knowledgebase/using-tribe_get_events/
*/
$args = array(
'eventDisplay' => 'custom',
'posts_per_page' => 1,
'meta_query' => array(
'relation' => 'AND',
'featured' => array(
'key' => Tribe__Events__Featured_Events::FEATURED_EVENT_KEY,
'compare' => 'EXISTS',
),
'start_date' => array(
'key' => '_EventStartDate',
'value' => current_time( 'mysql' ),
'compare' => '>=',
'type' => 'DATETIME',
),
),
'orderby' => array(
'start_date' => 'ASC',
),
);
$events = tribe_get_events( $args );