Skip to main content

Wordpress 2.0 not showing comment count

2 min read

There was a problem with my site after I upgraded to wordpress 2.0. It was never showing an updated comment count. It turns out this had to do with the SpamKarma2 plugin. There is no easy way to update the comment count value. Wordpress2 stores this comment_count value in the wp_posts table. Therefore I wrote a quick script that will update your site if you are having a similar problem.


Here is the script:



Just put it in a new file in your wp-admin directory - then visit it in your browser via the corresponding URL (if you follow the link save it as comment_count.php). After you visit the file it will just show you a blank page. However, it worked so make sure you delete it when you are done. To confirm it worked just view any post that wasn't showing the correct comment_count and see that now it is.


To anyone familiar with SQL at all you may think my approach is a little unrefined and it is. What follows is the code I wanted to use - however It didn't work with my version of mySQL. Honestly, I don't know if works with any version of mySQL or if maybe I just have a minor syntax error.


I believe the first example will work for all versions of mySQL but the second version will only work with MySQL 4.1 or later.