Table.php limit display of calendar to specific categories

Home Forums Calendar Products Events Calendar PRO Table.php limit display of calendar to specific categories

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #27069
    Sandro
    Participant

    I’m trying to make frontpage calendar to display only specific category events. Is it possible to make a filter so if table.php is on homepage, only events from specific category will be populated?

    Ideally I will have a variable $myCity on hopmepage, $myCity can be Paris or NewYork. Events calendar will also have categories “Paris” and “NewYork”, I want to use this variable to control display of calendar on homepage. So if $myCity == Paris, only events from that category will be loaded.

    Is this possible? Any ideas how I would modify query to attain this?

    For wordpress wp_query this is very easy since loops can be limited to category. I’m only having problem with calendar, as I’m not sure how it is done internally and could not find any ideas looking at the code.

    #27080
    Jonah
    Participant

    Hi Sandro,

    Yep, you can certainly do this. Basically in table.php the query for the calendar uses tribe_get_events(). I’m not sure how you’re displaying table.php on the home page (PHP include?) but you could add a condition before the first one on line 14 of table.php for:

    if(is_front_page()) {
    $eventPosts = tribe_get_events( array( 'eventCat' => $myCity, 'time_order' => 'ASC', 'eventDisplay'=>'month' ) );
    }

    ‘eventCat’ expects an ID so you’ll want to get the ID of the event category using something like what’s already there for event categories:

    $cat = get_term_by( 'slug', $myCity, $tribe_ecp->get_event_taxonomy() );
    $myCity = (int) $cat->term_id;

    Does that help?

    – Jonah

    #27098
    Sandro
    Participant

    Fantastic! works perfectly…

    #27148
    Jonah
    Participant

    Awesome! Glad that worked. Let us know if you need anything else.

    Regards,
    Jonah

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Table.php limit display of calendar to specific categories’ is closed to new replies.