Terms count includes Trashed and Draft Posts
I used wp-cli to update the category and post_tag terms on my website and the counts included both deleted (trashed) posts as well as draft posts that have never been published.
Since the Categories List and Tag Cloud blocks are public-facing and display these counts, this is a really bad experience for the site visitors. It even lists counts in categories that don't have any actual published posts and when clicking on it, it displays an empty page with no posts.
Can this please be fixed? And in the meantime, is there any other way, via extra parameters or something, to get the posts count accurate?
Thanks for the report, @timnicholson !
I was unable to reproduce following these steps:
- I created a new post in the WordPress admin, assigned a tag, and left the post as a draft.
- I ran
wp term update post_tag 5 --description='Foo Bar'to update the description of my term.
In the admin, I still see 0 as the post count:
Can you provide steps to reproduce the issue?
Hi, thanks for responding. I was mistaken about it counting non-published posts. It turns out what it was doing was counting non-posts! I have the category and tag hierarchy available for pages not just posts and so it was counting them. So instead of a bug, I would like to request an enhancement to be able to tell the term update command do only count posts not pages.
For now, I removed all categories from my pages and replaced them with tags instead since I'm not showing tag counts on my site.