Hide event category on all views and on all months

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.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1250401
    Kindra
    Participant

    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,
    Kindra

    #1251007
    Geoff
    Member

    Hi 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,
    Geoff

    #1251451
    Kindra
    Participant

    Thanks 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;
    }

    #1251711
    Geoff
    Member

    Hi 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!
    Geoff

    #1262640
    Support Droid
    Keymaster

    Hey 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

    #1798480
    Support Droid
    Keymaster

    Hey 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

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Hide event category on all views and on all months’ is closed to new replies.