Making the mini-calendar show specific categories

Home Forums Calendar Products Events Calendar PRO Making the mini-calendar show specific categories

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #30616
    Duncan
    Member

    I 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.

    #30633
    Jonah
    Participant

    Hey 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,
    Jonah

    #41885
    results
    Participant

    Hey 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

    #41918
    Jonah
    Participant

    Hey 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

    #41974
    results
    Participant

    That’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.

    #42055
    Jonah
    Participant

    You’re welcome Kim, I’m glad you got it working. Let us know if there’s anything else you need help with.

    Regards,
    Jonah

    #978775
    Support Droid
    Keymaster

    This 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.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Making the mini-calendar show specific categories’ is closed to new replies.