I’m using a filter on get_terms (see below) to remove a specified number of named categories from the “Manage Categories” listing. It works great, however, the excluded categories are still counted in the category count field that’s displayed just under the “Search Categories” button.
Is it possible that I can subtract these categories from the count?
function admin_edit_tags() {add_filter( 'get_terms', 'admin_trim_category_description', 10, 2 );}
function admin_trim_category_description( $terms, $taxonomies ){
if( 'category' != $taxonomies[0] )return $terms;
$my_categories = array('test1','test2','test3');
foreach( $terms as $key => $term)
if(in_array($terms[$key]->name, $my_categories)) { unset($terms[$key]);}
else
{
if(isset($terms[$key]->description) && $terms[$key]->description !=='') $terms[$key]->description = strip_tags(substr( $term->description, 0, 75 ))."...";
}
return $terms;
}
I think you should use
get_terms_args
filter instead ofget_terms
and just add exclude arg, so nowget_terms()
function won’t retrieve those cats and you’ll get right count. Here’s code example: