August 2009
S M T W T F S
« Jul   Sep »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

WordPress Bug: Incorrect count of comments? - Solution

Yeah, I’d been noticing it over the last few days that the count of comments for the posts was incorrect. And it was consistently missing out later posts. :-| I was unsure if the ‘bug’ existed in WordPress or it was due to the theme that I use (if that mattered).

I first thought, it probably didn’t count posts by the same person – or by the author… but that theory didn’t match for every post.

Googl’ing for the problem resulted in top 2-3 results which were tangential to my issue. So avoided that.

Tried some typical tricks… and finally, got the solution/”fix” for it: Just edit the comment for a post whose comment count is incorrect. You can simply add some character and delete it back, and then save it (Update Comment). You’ll now see that the count is corrected! :-)

God bless the WordPress programmers! They’re doing an awesome job – albeit some bugs (they’re kinda obvious, in software development). :-)

Enjoy!~



Luxury chocolate gifts from Hotel Chocolat


Generic CA US 300*250

Share This Post

3 comments to WordPress Bug: Incorrect count of comments? – Solution

  • Trisha Cupra

    Did you do an Import before this problem appeared?

    There is a bug that is triggered when you do an Import (perhaps after changing hosts, for instance).

    I had this problem on a blog I support with hundreds of posts(!). But I found a real solution at:

    http://wordpress.org/support/topic/265655

    All you need to do is copy and paste this code at the end of your Theme’s functions.php file:


    add_filter('get_comments_number', 'comment_count', 0);
    function comment_count( $count ) {
    if ( ! is_admin() ) {
    global $id;
    $comments_by_type = &separate_comments(get_comments('status=approve&post_id=' . $id));
    return count($comments_by_type['comment']);
    } else {
    return $count;
    }
    }

    It fixes all the posts at once!

    • Thanks Trisha… But no, I did not do an IMPORT before encountering the issue. I could only get it correct in the way I’ve mentioned in the blog above.

      Thanks anyway!

  • Steven Wu

    How do you physically edit the comment numbering? There is no way to do that in WordPress. Do you mean to edit it in the database?

    Hope you can help

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>