Skip to content

Instantly share code, notes, and snippets.

@dcooney
Last active January 5, 2022 18:47
Show Gist options
  • Save dcooney/2a4369bb7b2361a73539646a6ace6c49 to your computer and use it in GitHub Desktop.
Save dcooney/2a4369bb7b2361a73539646a6ace6c49 to your computer and use it in GitHub Desktop.
<?php
// id: team_filter, key: category
add_filter('alm_filters_team_filter_category', function(){
// Define empty array
$values = [];
// Get all categories
$args = array(
'order' => 'ASC',
'orderby' => 'name',
'exclude' => '1'
);
$terms = get_categories($args);
// Loop terms
if($terms){
// Add All Item
$values[] = array(
'label' => 'View All',
'value' => ''
);
foreach( $terms as $term ) {
$values[] = array(
'label' => $term->name,
'value' => $term->slug
);
}
}
return $values; // Return values
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment