I think you should use get_terms_args
filter instead of get_terms
and just add exclude arg, so now get_terms()
function won’t retrieve those cats and you’ll get right count. Here’s code example:
add_filter( 'get_terms_args', 'mamaduka_edit_get_terms_args', 10, 2 );
/**
* Exclude categories from "Edit Categories" screen
*
*/
function mamaduka_edit_get_terms_args( $args, $taxonomies ) {
if ( is_admin() && 'category' !== $taxonomies[0] )
return $args;
$args['exclude'] = array( 8, 10); // Array of cat ids you want to exclude
return $args;
}