How do i use tribe_events_filter_values to remove values from the filters

Home Forums Calendar Products Filter Bar How do i use tribe_events_filter_values to remove values from the filters

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #252580
    Nick Ritar
    Participant

    Can you please give me an example of how I might be able to remove the category “Cooking” from the available values in my category filters.

    I have a bunch of these convenience categories that were added for another purpose.

    I know this is a new feature, but i have not been able to find any snippets in the forum.

    Thanks
    Nick

    #253259
    Casey
    Participant

    Nick,
    Thanks for getting in touch! Can you explain a little bit more about where you’re wanting to remove these categories? Are you wanting to remove it from the ‘single event’ page, or somewhere else? Just give me a little more information, so I can help you further.

    Thanks! 🙂

    -Casey-

    #253535
    Nick Ritar
    Participant

    Hi Casey,

    The page is a photo listing of all events with the filter bar displayed across the top.

    http://staging01.laocoffee.com.au/courses/

    Apparently since the 3.6 release of Filter Bar….

    “Added a WordPress filter so that available values in the filters could be modified (‘tribe_events_filter_values’)”

    https://tri.be/support/forums/topic/release-versions-3-6-of-the-events-calendar-events-calendar-pro-all-add-ons/

    But yet to find an example of it being done.

    Cheers
    Nick

    #253563
    Casey
    Participant

    Nick,
    Take a look at this example: https://gist.github.com/jazbek/11382578 It shows you how to filter out a specific category from the filter dropdown. Hopefully that gets you started in the right direction, but let me know if you have further questions. Thanks! 🙂

    -Casey-

    #253765
    Nick Ritar
    Participant

    Awesome thanks Casey…. had to play with it a bit to get it to remove multiple, but the following worked great

    add_filter( ‘tribe_events_filter_values’, ‘tribe_filter_event_categories’, 10, 2 );
    function tribe_filter_event_categories( $values, $slug ) {
    if ( $slug == ‘eventcategory’ ) {
    foreach ( $values as $i => $category ) {
    if ( $category[‘name’] == ‘Cooking’ or $category[‘name’] == ‘Growing’ ) {
    unset ( $values[$i] );
    }
    }
    }
    return $values;
    }

    #255053
    Casey
    Participant

    Awesome! Thanks for confirming that this got you sorted. Since it looks like you’re all set, I’m going to mark this thread “Answered” and close it out.

    By the way, if you have a minute or two, we would love it if you’d write a few words for us here: http://m.tri.be/lo

    Thanks in advance. 🙂

    Cheers,
    Casey

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘How do i use tribe_events_filter_values to remove values from the filters’ is closed to new replies.