Home › Forums › Calendar Products › Filter Bar › How do i use tribe_events_filter_values to remove values from the filters
- This topic has 5 replies, 2 voices, and was last updated 9 years, 10 months ago by Casey.
-
AuthorPosts
-
June 26, 2014 at 4:54 am #252580Nick RitarParticipant
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
NickJune 26, 2014 at 11:24 am #253259CaseyParticipantNick,
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-
June 26, 2014 at 2:03 pm #253535Nick RitarParticipantHi 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’)”
But yet to find an example of it being done.
Cheers
NickJune 26, 2014 at 2:17 pm #253563CaseyParticipantNick,
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-
June 26, 2014 at 3:46 pm #253765Nick RitarParticipantAwesome 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;
}June 27, 2014 at 6:25 am #255053CaseyParticipantAwesome! 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 -
AuthorPosts
- The topic ‘How do i use tribe_events_filter_values to remove values from the filters’ is closed to new replies.