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?
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: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.Lastly, define the custom function
wpse50755_get_term_post_count_by_type
. This was taken from this answer.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.