Last active
June 16, 2016 21:16
-
-
Save geoffgraham/247cf5d7c7e618a60db9 to your computer and use it in GitHub Desktop.
Exclude specific categories from The Events Calendar month and list views
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
// Removes categories "dance" and "concert" from list and month views | |
add_action( 'pre_get_posts', 'exclude_events_category' ); | |
function exclude_events_category( $query ) { | |
if ( $query->query_vars['eventDisplay'] == 'list' && !is_tax(Tribe__Events__Main::TAXONOMY) || $query->query_vars['eventDisplay'] == 'month' && $query->query_vars['post_type'] == TribeEvents::POSTTYPE && !is_tax(Tribe__Events__Main::TAXONOMY) && empty( $query->query_vars['suppress_filters'] ) ) { | |
$query->set( 'tax_query', array( | |
array( | |
'taxonomy' => Tribe__Events__Main::TAXONOMY, | |
'field' => 'slug', | |
'terms' => array('dance', 'concert'), | |
'operator' => 'NOT IN' | |
) | |
) | |
); | |
} | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment