Skip to content

Instantly share code, notes, and snippets.

@jentheo
Created February 14, 2019 01:29
Show Gist options
  • Select an option

  • Save jentheo/4bc52c9148eec14d9afc8d1dba5cf82d to your computer and use it in GitHub Desktop.

Select an option

Save jentheo/4bc52c9148eec14d9afc8d1dba5cf82d to your computer and use it in GitHub Desktop.
Exclude category(ies) from main event views
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