Last active
February 20, 2024 13:36
-
-
Save cliffordp/1b8c808efa4256ebcef2d8805f069595 to your computer and use it in GitHub Desktop.
The Events Calendar - Get the next upcoming Featured Event
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment