Created
February 14, 2019 01:29
-
-
Save jentheo/4bc52c9148eec14d9afc8d1dba5cf82d to your computer and use it in GitHub Desktop.
Exclude category(ies) from main event views
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
| add_action( 'pre_get_posts', 'tribe_exclude_events_category' ); | |
| function tribe_exclude_events_category( $query ) { | |
| if ( ! is_singular( 'tribe_events' ) ) { | |
| if ( $query->query_vars['post_type'] == Tribe__Events__Main::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( 'alberta' ), | |
| 'operator' => 'NOT IN', | |
| ), | |
| ) ); | |
| } | |
| } | |
| return $query; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment