WordPress comment count

This statement corrects all the comment count in WP posts by querying every posts actual comments:

UPDATE wp_posts p SET p.comment_count = (
    SELECT count(*) FROM wp_comments
    WHERE comment_post_id = p.id AND
       comment_approved = 1 );

3 Comments to “WordPress comment count”

  1. steven 11 July 2009 at 17:29 #

    Where do we put this code?

  2. Jochen Lillich 11 July 2009 at 19:53 #

    @steven: You execute it on your WP installation’s database.

  3. Steven 11 July 2009 at 22:50 #

    How do I do that in PhpMyAdmin? I have no experience in Mysql is it possible you can give me a detailed run down how to go about it?Thank you so much


Leave a Reply