Home › Forums › Calendar Products › Events Calendar PRO › Making the mini-calendar show specific categories
- This topic has 6 replies, 4 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
January 10, 2013 at 9:19 pm #30616
Duncan
MemberI recently installed the PRO version of The Events Calendar and was surprised to see this wasn’t a feature! The ability to have the mini calendar display a specific category of events. After researching it on the web and in these forums, I couldn’t find anything for it. I’m not sure if this has been posted yet, but for anyone looking to do this, here’s how to do it.
Step 1. Allow arguments to be passed through the mini-grid function. Open up calendar.php (the-events-calendar/public/template-tags)
Scroll down to where the function tribe_calendar_mini_grid() is defined (line 34).Original:
———————————————–
function tribe_calendar_mini_grid() {
set_query_var( ‘eventDisplay’, ‘bydate’ );
load_template( TribeEventsTemplates::getTemplateHierarchy( ‘table-mini’ ) );
}
———————————————–Modified:
———————————————–
function tribe_calendar_mini_grid($mini_cat = ”) {
set_query_var( ‘eventDisplay’, ‘bydate’ );
if ($mini_cat != ”) {
set_query_var( ‘eventCat’, $mini_cat );
}
load_template( TribeEventsTemplates::getTemplateHierarchy( ‘table-mini’ ) );
}
———————————————–
If there’s a category passed as a string through the variable $mini_cat, it triggers set_query_var to change the wp_query parameters used by the calendar.Step 2. Make mini_table.php (the-events-calendar/views) use the category set by $mini_cat. Starting at line 28…
Original:
———————————————–
$eventPosts = tribe_get_events(array( ‘eventDisplay’=>’month’ ) );
———————————————–Modified:
———————————————–
if ( isset( $wp_query->query_vars[‘eventCat’] ) ) {
$EventCategory = $wp_query->query_vars[‘eventCat’];
$eventPosts = tribe_get_events( array( ‘eventCat’ => $EventCategory, ‘eventDisplay’=>’month’ ) );
} else {
$eventPosts = tribe_get_events(array( ‘eventDisplay’=>’month’ ) );
}
———————————————–
Save and upload. For templates, you can use:
tribe_calendar_mini_grid($mini_cat = ”);
and insert the category ID number inside the quotes.January 11, 2013 at 7:44 am #30633Jonah
ParticipantHey Duncan,
That’s an awesome hack, thank you for sharing. It should be noted that this approach is modifying core plugin files and these modifications will be lost upon update so be sure you are aware of this!
We do have this on our radar to add in a future version too.
Thanks,
JonahMarch 7, 2013 at 10:24 am #41885results
ParticipantHey Duncan !
I was searching for the exact same thing for the events calendar and I came across your post.
I followed the steps but for some reason it’s not working for me.
I’m not quite sure I understood the part where it says : “If there’s a category passed as a string through the variable $mini_cat,”
Would you be able to help me with this ?Thanks
March 7, 2013 at 1:02 pm #41918Jonah
ParticipantHey Kim, you should just be able to pass in a category ID like Duncan mentions here “For templates, you can use: tribe_calendar_mini_grid($mini_cat = ”); and insert the category ID number inside the quotes.”. So just do $mini_cat = “1” (or whatever your category ID is) and it should work.
– Jonah
March 8, 2013 at 5:50 am #41974results
ParticipantThat’s great, it Works !
Well I had done it exactly like that the first time but don’t know why it didn’t work. a typo in in the code maybe. But Anyways
Thanks for your support.March 8, 2013 at 2:36 pm #42055Jonah
ParticipantYou’re welcome Kim, I’m glad you got it working. Let us know if there’s anything else you need help with.
Regards,
JonahJuly 7, 2015 at 6:26 am #978775Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Making the mini-calendar show specific categories’ is closed to new replies.
