Skip to content

Instantly share code, notes, and snippets.

@jo-snips
Last active June 5, 2023 01:02
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jo-snips/5338806 to your computer and use it in GitHub Desktop.
Save jo-snips/5338806 to your computer and use it in GitHub Desktop.
The Events Calendar - Exclude Events by Category (pre_get_posts)
<?php
add_action( 'pre_get_posts', 'exclude_events_category' );
function exclude_events_category( $query ) {
if ( tribe_is_event() && !tribe_is_day() && !is_single() && !is_tax() && !tribe_is_month() ) {
$query->set( 'tax_query', array(
array(
'taxonomy' => TribeEvents::TAXONOMY,
'field' => 'slug',
'terms' => array('zoo'),
'operator' => 'NOT IN'
)
)
);
}
return $query;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment