Home › Forums › Calendar Products › Events Calendar PRO › Multiple Calendar links with different sets of categories
- This topic has 4 replies, 2 voices, and was last updated 11 years, 7 months ago by
Geoff.
-
AuthorPosts
-
October 9, 2014 at 8:14 am #798710
mcdanielsmarketing
ParticipantI’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[]=1My 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)
October 9, 2014 at 9:36 am #798895Geoff
MemberHi 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!
GeoffOctober 9, 2014 at 2:26 pm #799368mcdanielsmarketing
ParticipantAwesome, 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.
October 10, 2014 at 7:27 am #800747Geoff
MemberGood 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!
GeoffOctober 10, 2014 at 1:33 pm #801510Geoff
MemberThanks 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 -
AuthorPosts
- The topic ‘Multiple Calendar links with different sets of categories’ is closed to new replies.
