[ Taxonomy filter dropdown ] – posts count by term
I’m wondering if it’s possible to see the posts count by taxonomy term in the filter dropdown for a custom taxonomy column (next to each term)
I think I saw that in some default WP admin screens but can’t find it anymore
thanks for a great plugin
Thanks for your feedback. In the current release this is not possible, but we had this request before and already made a feature request for this. I just implemented this for the upcoming release. We put the solution in an option so you can choose to show the term count for both inline edit and filtering.
will be quite useful!
thanks a lot
You’re welcome. It will be shipped in Admin Columns 4.0 which is planned for April 4th.
I will close this topic.
I’m sorry to say this but we just had to remove this feature from the 4.0 release. Although you’ll only need 1 line of code to show the term count, we removed it from the upcoming release because it will give some confusing results.
Say you have a taxonomy that is related to multiple post types. Our first fix will show the post count in the filter dropdown, but this count is based on post types, since we just use the total count that we get from the WordPress function
get_terms. So when you only have used a taxonomy for post_type x and you filter on that taxonomy in post_type y, you’ll get 0 results.
So we have to think more about this solution and for example only show the taxonomies in the dropdown that are used for the specific post types. This is absolutely doable but seen the time we need to develop and test this, we decided to move this issue to a next release. I can give you the code after we’ve released the new version so you can change it in your version as a temporary workaround.
Thanks a lot Stefan,
may be obvious but I’m confused by:
So when you only have used a taxonomy for post_type x and you filter on that taxonomy in post_type y, you’ll get 0 results.
why would you filter on a Taxonomy for a post type you have not associated the taxonomy to?
no worries if you have no time to answer
just give me an example if you have time
and I’ll welcome the code of course
Sorry, I did explain myself wrong. I mean that the taxonomy is associated the both post types but the specific term is not. The filter dropdown shows all used terms for the taxonomy and does not look if a term is used for the specific post type. Therefor it is possible to filter on a term that is not used on any of the posts in current post type. I hope this makes sense.
yes I understand,
it’s quite clear now,
only it seemed to me that when a term is not associated to any post for a specific post type the term would not show up in the dropdown at all
this happens if the terms associated posts count is 0 for this term and post type
but I’d need to re-check that
do I make sense?
I think you’re partially right.
We just do a
get_terms() and there is a param
hide_empty which is set to true by default.
So yes, if a term is not used on any post type, the taxonomy is not shown in the list. But it will show up in Post type a when it is only associated to post type b.
We have to create a new method like
Thanks for all your input so far!
You must be logged in to reply to this topic.