I have created a custom taxonomy 'season' I have 3 custom post types which I want to use this taxonomy. These are

  • Races
  • Galleries
  • Competitors

Now, when I view the totals within the taxonomy screen (i.e. the URL in the wp-admin is showing: edit-tags.php?taxonomy=season&post_type=race)

The totals are showing the combined number of posts in this category across all my custom posts, and not just the number of 'race' posts which fall into this category.

Why is this? and how do I get the taxonomy to only show this custom post type?

enter image description here

1 Answer 1


There is currently a trac ticket on the fact that taxonomy counts are global (include all post types). Related trac ticket.

To fix this you can remove the column and add your own using the manage_edit-{$taxonomy}_columns filter:

function my_season_columns($columns){
    $columns['cpt_count'] = 'Races';

    return $columns;

You then tell WordPress what to fill this column with using the manage_{$taxonomy}_custom_column filter. For this you check we are in the 'cpt_count' column and return what ever the count is. You'll need a custom function to do this.

function my_season_alter_count($value, $column_name, $id ){
    if( 'cpt_count' == $column_name )
        return wpse50755_get_term_post_count_by_type($id,'season','race');

    return $value;

Lastly, define the custom function wpse50755_get_term_post_count_by_type. This was taken from this answer.

function wpse50755_get_term_post_count_by_type($term,$taxonomy,$type){

  $args = array( 
    'fields' =>'ids',
    'numberposts' => -1,
    'post_type' => $type, 
     'tax_query' => array(
            'taxonomy' => 'event-category',
            'field' => 'id',
            'terms' => intval($term)
   $ps = get_posts( $args );

   if (count($ps) > 0){
       return count($ps);
       return 0;

This is untested, but conceptually it should work.

You'll need to do a bit more work to make the column sortable, since you'll need to work out how to tell WordPress to sort the terms in count (post type specific) order.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.