Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jesseeproductions
Created February 19, 2020 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesseeproductions/65e8d15858bf63801fdc26508d151b2a to your computer and use it in GitHub Desktop.
Save jesseeproductions/65e8d15858bf63801fdc26508d151b2a to your computer and use it in GitHub Desktop.
Exclude Categories from The Events Calendar New Views
add_filter( 'tribe_events_views_v2_view_list_repository_args', 'filter_categories_from_v2_views', 20 );
add_filter( 'tribe_events_views_v2_view_month_repository_args', 'filter_categories_from_v2_views', 20 );
/**
* Exclude Categories from The Events Calendar New Views
* For TEC 5.0 and Greater
*
* @param array $repository_args An array of query variables.
*
* @return array An array of query variables.
*/
function filter_categories_from_v2_views( $repository_args ) {
if ( is_singular() || is_admin() ) {
return $repository_args;
}
if ( is_tax( Tribe__Events__Main::TAXONOMY ) ) {
return $repository_args;
}
$repository_args['tax_query'] = array(
array(
'taxonomy' => Tribe__Events__Main::TAXONOMY,
'field' => 'slug',
'terms' => array( 'exhibitions' ),
'operator' => 'NOT IN'
)
);
return $repository_args;
}
@benklocek
Copy link

I'm curious why you used tribe_events_views_v2_view**list**repository_args instead of tribe_events_views_v2_view_repository_args?

I'm trying to do something similar with a passed in variable, and having trouble getting that changes to stick when the next link is pressed. My filters don't seem to be in effect when loaded via ajax.

@benklocek
Copy link

Just found this: https://docs.theeventscalendar.com/reference/hooks/tribe_events_views_v2_view_this-slug_repository_args/ Thanks for making your v2 views gists available :D

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