Multiple Calendar links with different sets of categories

Home Forums Calendar Products Events Calendar PRO Multiple Calendar links with different sets of categories

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #798710
    mcdanielsmarketing
    Participant

    I’m trying to set up multiple buttons in the menu that go to different versions of our calendar. I want a Birthday Calendar, that just shows events with the category:Birthdays, and I want a Calendar that shows everything BUT Birthdays.

    I can set up the birthday calendar link like this:
    /events/?tribe_eventcategory[]=28
    where 28 is the birthday category number.

    And then the main calendar link would have all the other categories in it:
    /events/?tribe_eventcategory[]=23&tribe_eventcategory[]=15&tribe_eventcategory[]=26&tribe_eventcategory[]=1

    My problem: The main calendar still misses some events. I can include “uncategorized” as one of the included categories, but whoever adds the event has to manually click “uncategorized” – which they won’t do.

    I need to be able to either: force a default event category, or exclude certain events from particular calendar views. Can I do either of these?

    (note: I also have Filter Bar)

    #798895
    Geoff
    Member

    Hi there, Melissa! Thanks for getting in touch and welcome to the forums. We hope you’re enjoying the plugins so far. 🙂

    You’re definitely on the right track. Each category has its own unique URL that can be linked to directly. For example, a category called “Birthday” can be linked to at: [your-site]/events/category/birthday.

    It’s definitely possible to exclude specific categories from the Month view with a little customization. Try adding this to your theme’s functions.php file, where “category-1” and “category-2” are the categories you want to exclude:

    add_action( 'pre_get_posts', 'exclude_events_category' );
    
    function exclude_events_category( $query ) {
    if ( $query->query_vars['eventDisplay'] == 'upcoming' && !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(‘category1’, <code>category-2</code>),
    'operator' => 'NOT IN'
    )
    
    )
    );
    }
    return $query;
    }

    Does that make sense? Will that work for you? Please let me know.

    Cheers!
    Geoff

    #799368
    mcdanielsmarketing
    Participant

    Awesome, thanks Geoff.

    Will that change month view so it always works that way? I’d like to be able to see the Month view for just Birthdays, and then click another button to see Month view for everything else.

    #800747
    Geoff
    Member

    Good question. That snippet will exclude categories in the main Month view, but you will still be able to access the excluded categories using their direct link. For example, the category “Birthday” can still be viewed at: [your-site]/events/category/birthday.

    Does this help answer your question? Please let me know.

    Cheers!
    Geoff

    #801510
    Geoff
    Member

    Thanks for confirming the answer, Melissa! Much appreciated. 🙂

    I’m going to go ahead and close this thread, but please feel free to hit us up with a new thread if any other questions pop up. We’d be happy to help.

    Cheers!
    Geoff

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Multiple Calendar links with different sets of categories’ is closed to new replies.