Created
March 31, 2012 22:11
-
-
Save jkudish/2269019 to your computer and use it in GitHub Desktop.
Exclude a specific category from Events Grid View
This file contains hidden or 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 | |
/** | |
* Exclude a specific category from Events Grid View | |
* | |
* @author jkudish | |
* @uses pre_get_posts filter | |
* @param object $query the query object | |
* @return object $query the filtered object | |
*/ | |
add_action( 'pre_get_posts', 'exclude_events_category' ); | |
function exclude_events_category( $query ) { | |
if ( $query->query_vars['post_type'] == TribeEvents::POSTTYPE && $query->query_vars['eventDisplay'] == 'month' && !is_tax(TribeEvents::TAXONOMY) && empty( $query->query_vars['suppress_filters'] ) ) { | |
$query->set( 'tax_query', array( | |
array( | |
'taxonomy' => TribeEvents::TAXONOMY, | |
'field' => 'slug', | |
'terms' => array('not-in-this-category'), | |
'operator' => 'NOT IN' | |
) | |
) ); | |
} | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment