Home › Forums › Calendar Products › Events Calendar PRO › Remove Category from Calendar and List Views
- This topic has 1 reply, 2 voices, and was last updated 5 years, 9 months ago by Melanie Adcock.
-
AuthorPosts
-
July 17, 2018 at 8:50 am #1577206Melanie AdcockParticipant
I scoured the forum looking for some code to do this. I found the following but now it is throwing an error but I don’t understand the error:
The error:
Notice: Undefined index: eventDisplay in /nas/content/staging/newleaderdog/wp-content/themes/leaderdog_child/functions.php on line 181The code:
/ Removes categories “puppy raisers” from list and month views
add_action( ‘pre_get_posts’, ‘exclude_events_category’ );
function exclude_events_category( $query ) {
if ( ! is_singular( ‘tribe_events’) && ! is_page(3434) && $query->query_vars[‘eventDisplay’] == ‘list’ && !is_tax(TribeEvents::TAXONOMY) || $query->query_vars[‘eventDisplay’] == ‘month’ && $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(‘puppy-raisers’),
‘operator’ => ‘NOT IN’
)
)
);
}
return $query;
}Thanks.
MelanieJuly 17, 2018 at 12:05 pm #1577490CliffMemberHi, Melanie.
I didn’t review all of your code, but that error means you should add a check if eventDisplay is empty, like this:
if ( ! is_singular( 'tribe_events') && ! is_page(3434) && ! empty( $query->query_vars['eventDisplay'] ) && ...
(or, if that that, then something close to it)
Please let me know how this goes for you.
August 8, 2018 at 9:35 am #1593068Support 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 ‘Remove Category from Calendar and List Views’ is closed to new replies.