Forums

comment count zero after import (9 posts)

  1. kcmartin
    Member
    Posted 2 years ago #

    I couldn't find an adequate solution to this in the forum so am hoping that someone can help me!

    After importing posts from another wordpress blog the comment count has been set to zero, even if there are comments on a post. The comments are not disabled either.

    The comment count is working fine for all posts created since the import.

    How can I reset the comment count for the imported posts?

  2. Tommie Hansen
    Member
    Posted 2 years ago #

    I wonder this to. The problem is obviosly that some values are left out in the db. :f Got the same problems but with local avatars not being set to new ones for old users etc.

    Some re-count feature would fix it.

  3. ddysart
    Member
    Posted 2 years ago #

    +1 on this one. I have a blog I support where I'm seeing this.

  4. trishacupra
    Member
    Posted 2 years ago #

    I had this problem today, too, and found the solution at http://wordpress.org/support/topic/265655

    Here is the solution:

    Add this code to 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;
    }
    }

    All fixed!

  5. burpexcuzme
    Member
    Posted 2 years ago #

    It's still not working for me! :-(

  6. kcmartin
    Member
    Posted 2 years ago #

    Thank you Trisha! It worked to the extend that my posts now show the correct comment count. However, my archives still don't for those posts that I imported, see here http://www.gipsylife.com/archives/. If you expand all posts you can see that everything after May 2009 shows a (0) count even though there are comments. I guess this now is a problem with the plug-in *sigh*. Wish I was more technical!

  7. freshmess
    Member
    Posted 2 years ago #

    Hi trishacupra, at which part in the functions.php file do I insert that code? When I pasted this code on the functions.php (removing everything that was in there first), it turns into an error message, even my blog only displays that error message. Please help? Thanks!

  8. freshmess
    Member
    Posted 2 years ago #

    Got it!

  9. Anonymous
    Unregistered
    Posted 2 years ago #

    Thanks trishacupra! it works!

Topic Closed

This topic has been closed to new replies.

About this Topic