entity-command icon indicating copy to clipboard operation
entity-command copied to clipboard

Terms count includes Trashed and Draft Posts

Open timnicholson opened this issue 3 years ago • 2 comments

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?

timnicholson avatar Sep 05 '23 00:09 timnicholson

Thanks for the report, @timnicholson !

I was unable to reproduce following these steps:

  1. I created a new post in the WordPress admin, assigned a tag, and left the post as a draft.
  2. 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:

CleanShot 2023-09-07 at 13 25 24@2x

Can you provide steps to reproduce the issue?

danielbachhuber avatar Sep 07 '23 20:09 danielbachhuber

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.

timnicholson avatar Sep 16 '23 18:09 timnicholson