Last active
October 10, 2017 21:58
-
-
Save jentheo/676f4c627246db43ad36a3d484ebb91e to your computer and use it in GitHub Desktop.
Exclude certain categories from all views (except category pages)
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 | |
/* | |
* The Events Calendar Remove Events from All Views (Except Category Pages) | |
* add to theme's functions.php file | |
* @version 4.5.5 | |
* replace these example slugs with your event category slugs: array( 'family-fun', 'bbq' ) | |
*/ | |
add_action( 'pre_get_posts', 'tribe_exclude_events_categories_all_views' ); | |
function tribe_exclude_events_categories_all_views( $query ) { | |
if ( $query->query_vars['post_type'] == Tribe__Events__Main::POSTTYPE && isset( $query->query_vars['eventDisplay'] ) && ! is_singular( 'tribe_events' ) && ! is_tax( Tribe__Events__Main::TAXONOMY ) ) { | |
{ | |
$query->set( 'tax_query', array( | |
array( | |
'taxonomy' => Tribe__Events__Main::TAXONOMY, | |
'field' => 'slug', | |
'terms' => array( 'family-fun', 'bbq' ), | |
'operator' => 'NOT IN' | |
) | |
) ); | |
} | |
} | |
return $query; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment