Home › Forums › Calendar Products › Events Calendar PRO › Fiter category function not working on Week View
- This topic has 5 replies, 2 voices, and was last updated 9 years, 6 months ago by Barry.
-
AuthorPosts
-
September 17, 2014 at 9:50 am #748744smazzoniParticipant
Hello again, I’m having some problems to filter a category on the Week View, while the function you posted here on the forums works perfectly
add_action( ‘pre_get_posts’, ‘exclude_events_category’ );
function exclude_events_category( $query ) {
if ( $query->query_vars[‘post_type’] == TribeEvents::POSTTYPE && !is_tax(TribeEvents::TAXONOMY) && empty( $query->query_vars[‘suppress_filters’] ) ) {
$query->set( ‘tax_query’, array(
array(
‘taxonomy’ => TribeEvents::TAXONOMY,
‘field’ => ‘slug’,
‘terms’ => array(‘nightlife-bars-clubs’),
‘operator’ => ‘NOT IN’
)
)
);
}
return $query;
}This doesn’t work on the Week View, is there a workaround for this? Thanks!
September 18, 2014 at 8:46 am #750771BarryMemberHi – thanks for posting.
That snippet seems to work as expected when I test it, in list view and in week view (no events from my test category displayed).
Is there any further information you can provide/have you tried it out after deactivating all other plugins and switching to a default theme, as described in our post on looking for conflicts? It could definitely be worth adding this snippet when no other plugins and only a default theme are enabled and seeing if it works then.
Thanks!
September 18, 2014 at 9:07 am #750815smazzoniParticipantHi Barry,
Now I figure out that only works on the Monthly View, isn’t working on Day, Week nor Map view (maybe because these views are built with JS?)
What I did is to put the function on functions.php of my theme, and calling it at the top of the default-template of the tribe-events folder:
add_action( ‘pre_get_posts’, ‘exclude_events_category’ );
Am I doing something wrong?
September 18, 2014 at 11:52 am #751267BarryMemberYes: please put your add_action() call in your functions.php file, along with the function itself. Does that help?
September 18, 2014 at 2:11 pm #751516smazzoniParticipantWorking perfectly now, thank you Barry 🙂
September 19, 2014 at 6:44 am #752876BarryMemberMy pleasure 🙂
I’ll go ahead and close this thread as it looks like you’re all sorted – but please don’t hesitate to create new threads as needed if we can assist with anything else.
Also, if you have a moment, we’d love to hear your thoughts on The Events Calendar across on our plugin review page – thanks again!
-
AuthorPosts
- The topic ‘Fiter category function not working on Week View’ is closed to new replies.