Home › Forums › Calendar Products › Events Calendar PRO › Hide event category on all views and on all months
- This topic has 5 replies, 4 voices, and was last updated 7 years ago by Kindra.
-
AuthorPosts
-
March 7, 2017 at 6:57 am #1250401KindraParticipant
Hello,
I was able to hide an event category on the landing page of a calendar, but if users click over to subsequent months, they can see the hidden category. How can I remove a category from the main calendar alltogether.
e.g. the events landing page is okay, but the paged pages show the hidden category: https://www.theedgewater.com/events/ vs https://www.theedgewater.com/events/?action=tribe_photo&tribe_paged=1&tribe_event_display=past
Thank you,
KindraMarch 8, 2017 at 7:21 am #1251007GeoffMemberHi Kindra,
Will you tell me what category you are referring to and how you are currently attempting to hide it from the calendar views? That will help me test around on your site a bit and see if I can’t come up with some suggestions.
I do want to note that we are fairly limited in being able to support custom development. That said, I’m absolutely happy to help guide you here as best I can!
Cheers,
GeoffMarch 8, 2017 at 6:45 pm #1251451KindraParticipantThanks Geoff!
Here is the code snippet I’m using – the category is “spa”. Ideally I’d like the spa events to NEVER show up in the main calendar – in any view!
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’] == ‘photo’ || $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(‘spa’),
‘operator’ => ‘NOT IN’
)
)
);
}
return $query;
}March 9, 2017 at 7:04 am #1251711GeoffMemberHi Kindra,
Thanks for following up!
Looks like that snippet is based on a slightly outdated version and was only set to work in Photo View. Give this a try instead:
add_action( 'pre_get_posts', 'exclude_events_category' ); function exclude_events_category( $query ) { if ( $query->query_vars['post_type'] == Tribe__Events__Main::POSTTYPE && $query->query_vars['eventDisplay'] == 'photo' || $query->query_vars['eventDisplay'] == 'list' || $query->query_vars['eventDisplay'] == 'month' || $query->query_vars['eventDisplay'] == 'week' || $query->query_vars['eventDisplay'] == 'day' || $query->query_vars['eventDisplay'] == 'past' && !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('spa'), 'operator' => 'NOT IN' ) ) ); } return $query; }
This one looks for events in the Spa category and attempts to hide those events in all views. It seemed to work when I gave it a quick test, but I did not test it extensively. I hope it does the trick for you, or at least helps give you something new to work with and modify further.
Cheers!
GeoffMarch 31, 2017 at 9:35 am #1262640Support DroidKeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support TeamApril 27, 2019 at 9:35 am #1798480Support DroidKeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Hide event category on all views and on all months’ is closed to new replies.