Hide Specific Filter Bar Categories

Home Forums Calendar Products Events Calendar PRO Hide Specific Filter Bar Categories

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1318427
    Wesley E Childers
    Participant

    I have added the functions.php code detailed elsewhere on these forms but I’m seeing the same strange issue mentioned on this thread where every-other category in the array is not being hidden. It looks like the thread was closed before a solution was documented:

    https://theeventscalendar.com/support/forums/topic/hide-categories-from-filter-bar/

    Any idea how to fix this? I have a long list of sub-categories I need to hide to make the filter bar more manageable/usable on my site.

    #1319521
    Barry
    Member

    Hi Wesley,

    Thanks for posting!

    One thing I should point out right away is that – though we do share snippets in an effort to point users like yourself in the right direction – custom development tasks are generally something we need to leave in your hands.

    Here’s an alternative snippet you might try, loosely based on the one in the topic you mentioned, which takes a list of category slugs and removes them from Filter Bar’s category filter. Want to give that a try?

    function remove_specific_categories_from_filterbar( $values, $filter_slug ) {
    	if ( 'eventcategory' !== $filter_slug ) {
    		return $values;
    	}
    
    	$unwanted = array( 'category-slug-1', 'category-slug-2', /* more slugs as needed */  );
    
    	foreach ( $values as $key => $value ) {
    		if ( in_array( $value['data']['slug'], $unwanted ) ) {
    			unset( $values[ $key ] );
    		}
    	}
    
    	return $values;
    }
    
    add_filter( 'tribe_events_filter_values',  'remove_specific_categories_from_filterbar', 10, 2 );
    

    Hopefully it helps or at least gets you started in the right direction 🙂

    #1329521
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Hide Specific Filter Bar Categories’ is closed to new replies.