WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

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.

share|improve this answer
thanks for the comprehensive answer – Ash May 1 '12 at 17:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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