Skip to content

Instantly share code, notes, and snippets.

@barryhughes
Created December 12, 2014 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barryhughes/82dcf2a959b2951ffc2a to your computer and use it in GitHub Desktop.
Save barryhughes/82dcf2a959b2951ffc2a to your computer and use it in GitHub Desktop.
Quick hack to remove a specific category from the Filter Bar (3.9) output
/**
* You could add this snippet to your theme's functions.php file
* or any other suitable location.
*/
add_filter( 'tribe_events_filter_values', 'filter_categories_in_category_filter', 10, 2 );
/**
* Handles modifying the list of event categories within Filter Bar.
*
* @param $values
* @param $filter_slug
* @return mixed
*/
function filter_categories_in_category_filter( $values, $filter_slug ) {
// For any other filter, return the value list unmodified
if ( 'eventcategory' !== $filter_slug ) return $values;
// This is the *name* of the category we wish to remove
$to_remove = 'Jolly Japes and Adventures';
// Find and remove the category if it exists: this could be extended for
// better handling of parent/child categories if needed
foreach ( $values as $index => $item )
if ( $to_remove === $item['name'] ) unset( $values[$index] );
// Return our modified list
return $values;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment