Home › Forums › Calendar Products › Events Calendar PRO › Exclude category from month, list, week, day view
- This topic has 3 replies, 2 voices, and was last updated 11 years, 4 months ago by
Brook.
-
AuthorPosts
-
November 19, 2014 at 7:01 am #890610
Chris Titley
ParticipantHi there. Thanks for a great bit of kit.
We run a website for the city of York, UK, with a lot of events to include daily.
We want to exclude long-running exhibitions from the main list of events (including all the views: list, month, week, day, map) as they dominate to the detriment of new events.
For readers interested in exhibitions, we would direct them to the specific url where they are listed.
We have tried adding the code below, as suggested in another thread (’89’ is the ID no of the category ‘Exhibition’, but it didn’t work.
What are we doing wrong please?
Best wishes,
Chris
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('89'), 'operator' => 'NOT IN' ) ) ); } return $query; } </pre>November 19, 2014 at 1:16 pm #891016Brook
ParticipantHowdy Chris,
Good question. Two problem stand out, first of all this line will exclude the script form running on month views. It sounds like you don’t want that to happen.
if ( tribe_is_event() && !tribe_is_day() && !is_single() && !is_tax() && !tribe_is_month() ) {
And the second issue is that you are using the category ID, not it’s slug on this line:
‘terms’ => array(’89’),
I think if you address those two problems it will work from the looks of it. If you are not super familiar with PHP and the WP API, sometimes it is nice to have folks around who can help! We can only do limitted debugging from afar. But hopefully once you address those two issues we will have a happy outcome. Please let me know the result. Thanks!
– Brook
December 10, 2014 at 11:39 pm #914964Brook
ParticipantSince this has gone for a spell without a response, I am going to archive it. If for some reason your issue is not resolved please open a new topic. We’d love to continue helping. Cheers!
– Brook
December 10, 2014 at 11:40 pm #914968Brook
ParticipantSince this has gone for a spell without a response, I am going to archive it. If for some reason your issue is not resolved please open a new topic. We’d love to continue helping. Cheers!
– Brook
-
AuthorPosts
- The topic ‘Exclude category from month, list, week, day view’ is closed to new replies.
