Hi,
I’m attempting to exclude a category from the main calendar page (all views). I’ve found several variations of the answer given here: https://theeventscalendar.com/support/forums/topic/exclude-one-category-from-upcoming-events-list/#post-46807
I’ve added these to my child themes functions.php file and it has no effect.
Here is my code:
// from http://snippi.com/s/rd9pqcd
add_action( ‘pre_get_posts’, ‘exclude_events_category’ );
function exclude_events_category( $query ) {
if ( $query->query_vars[‘post_type’] == TribeEvents::POSTTYPE && $query->query_vars[‘eventDisplay’] == ‘upcoming’ || $query->query_vars[‘eventDisplay’] == ‘past’ && !is_tax(TribeEvents::TAXONOMY) && empty( $query->query_vars[‘suppress_filters’] ) ) {
$query->set( ‘tax_query’, array(
array(
‘taxonomy’ => TribeEvents::TAXONOMY,
‘field’ => ‘slug’,
‘terms’ => array(‘replaced-with-slug-of-excluded-category’),
‘operator’ => ‘NOT IN’
)
)
);
}
return $query;
}
I noticed these answers were from The Events Calendar PRO forum. Should this solution be working with the standard version?
Is there a different solution for the standard version to exclude categories?
Thanks in advance.