WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Comment count always zero (5 posts)

  1. Susan
    Member
    Posted 5 years ago #

    The comment count on my blog is zero for every post even those that have 1, 2 or more comments.

    All of these functions think there are no comments:
    comments_popup_link
    and
    comments_number

    but.. all the comments are still displayed properly.

    I have no idea how to fix this. Any ideas?

  2. webgirl
    Member
    Posted 4 years ago #

    Will mind sharing how this was resolved?

  3. Chintaru
    Member
    Posted 4 years ago #

    I have the same issue after importing a xml backup, but I found a solution:

    Paste this in your functions.php in your theme's folder:

    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;
    }
    }
  4. Trisha Cupra
    Member
    Posted 4 years ago #

    This works beautifully!

    I'm sharing this solution on all the other unresolved threads and on blogs I found (in my search for this solution) where other people are having this problem but couldn't find a fix.

  5. jtlowe22
    Member
    Posted 4 years ago #

    I experienced the same problem when importing a WordPress 2.5 export into WordPress 2.9

    Thanks for the solution.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags