WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've received an old wordpress 2.8 and successfully upgraded to WP3.2.1. I've just discovered that the amount of comments displayed in the WP Admin 's list of posts is wrong.

Would you know how i could fix that by, perhaps, running a clever SQL update query in the database, that would fetch the real number of comments associated to a post and update the post row accordingly?

share|improve this question

I nailed it:

UPDATE wp_posts as p SET comment_count =(SELECT count(*) FROM `wp_comments` WHERE `comment_post_ID`=p.ID);
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.