'Wordpress: Deleted comments in DB but still shows count in admin sidebar. How can I fix this?

I noticed a lot of spam posts, comments, & users on my WordPress site. I directly deleted all of the spam from the database, but I'm still seeing a comment count in the sidebar and on the edit-comments.php page as if I never deleted anything. I cannot figure out where this number is coming from and would like to fix it.

WP v5.7.2 with a BeTheme theme.



Solution 1:[1]

I just had this issue.

  1. In the WP database, I searched and wanted to delete any pending comments. I did not have any.
  2. I cleaned the browser and Wordpress cache.
  3. I created a new post and added a comment.
  4. I deleted my new comment and then the post.

The number of pending comments went down to zero as I wanted.

This is not the professional way of solving this issue but allowed me to move on. I'll post if I find a better way to clear this incorrect "pending messages count number".

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1