Created
May 17, 2013 16:49
-
-
Save stephenharris/5600396 to your computer and use it in GitHub Desktop.
Excludes specified event categories from any event query. Untested.
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 | |
/** | |
* Excludes specified event categories from any event query. Untested. | |
*/ | |
add_action( 'pre_get_posts','harris_exclude_event_terms' ); | |
function harris_exclude_event_terms( $query ) { | |
if ( $query->is_main_query() && eventorganiser_is_event_query( $query ) ) { | |
$tax_query = $query->get( 'tax_query' ); | |
$tax_query['relation'] = 'AND'; | |
$tax_query[] = array( | |
'taxonomy' => 'event-category', | |
'field' => 'id', | |
'terms' => array( 'my-slug', 'my-other-slug' ), | |
'operator' => 'NOT IN' | |
); | |
$query->set( 'tax_query', $tax_query ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment