Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Removes categories "tech" from list and month views
/*
* The Events Calendar Remove Events from Month and List Views
* add coding to theme's functions.php
* @version 3.12
* modify here with event category slugs: array( 'concert', 'convention' )
*/
add_action( 'pre_get_posts', 'tribe_exclude_events_category_month_list' );
function tribe_exclude_events_category_month_list( $query ) {
if ( isset( $query->query_vars['eventDisplay'] ) && ! is_singular( 'tribe_events' ) ) {
if ( $query->query_vars['eventDisplay'] == 'list' && ! is_tax( Tribe__Events__Main::TAXONOMY ) || $query->query_vars['eventDisplay'] == 'month' && $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( 'concert', 'convention' ),
'operator' => 'NOT IN'
)
) );
}
}
return $query;
}
@la-com

This comment has been minimized.

Copy link

@la-com la-com commented May 17, 2019

Hello,
Thank you for this snipped! Is there a way to force the exclusion only on the general event calendar?
I'd like to display the category on widget and on the organizer page, but the snipped hide them on these places…
Or maybe add || places || organizer || widget
But I don't how to write the code :'(

@la-com

This comment has been minimized.

Copy link

@la-com la-com commented May 17, 2019

I've tried this but it doesn't work:
if ( $query->query_vars['eventDisplay'] == 'list' && ! is_tax( Tribe__Events__Main::TAXONOMY ) || $query->query_vars['eventDisplay'] == 'month' && ! $query->tribe_is_event_venue && ! $query->tribe_is_event_organizer && $query->query_vars['post_type'] == Tribe__Events__Main::POSTTYPE && ! is_tax( Tribe__Events__Main::TAXONOMY ) && empty( $query->query_vars['suppress_filters'] ) ) {

@Zodiac1978

This comment has been minimized.

Copy link

@Zodiac1978 Zodiac1978 commented Jan 18, 2020

Does not work anymore unfortunately. Do you have an idea how to fix this code @jesseeproductions?

@Zodiac1978

This comment has been minimized.

@jesseeproductions

This comment has been minimized.

Copy link
Owner Author

@jesseeproductions jesseeproductions commented Jan 20, 2020

@Zodiac1978 - Thanks for linking to a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment