Created
December 12, 2014 15:57
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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