Created
May 3, 2018 19:16
-
-
Save barryhughes/70c1da206f7bd1b828f3295e0646a61f to your computer and use it in GitHub Desktop.
Removes featured events from event queries, unless the query is specifically for featured events
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 | |
/** | |
* Remove featured events from event queries, unless the query | |
* is specifically for featured events. | |
*/ | |
add_action( 'tribe_events_pre_get_posts', function( $query ) { | |
if ( tribe( 'tec.featured_events' )->is_featured_query( $query ) ) { | |
return; | |
} | |
$meta_query = (array) $query->get( 'meta_query' ); | |
$meta_query[] = array( | |
'key' => Tribe__Events__Featured_Events::FEATURED_EVENT_KEY, | |
'compare' => 'NOT EXISTS' | |
); | |
$query->set( 'meta_query', $meta_query ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment