:mhfs


Comments Count Bug in iNove WP Theme

Well… I was looking into the blog thinking about what would be the next post when I noticed that some unapproved spam comments were being taking into consideration in the iNove theme comments’ count.

A post was stating “1 comment” but when I clicked on that it took me to the post detail page where there was no comment.

After trying a little by myself I ended up asking for help in the #wordpress irc channel on freenode.

Thanks to sivel I was able to correct a small bug in functions.php.

On line 363 (3 below)

function comment_count($commentcount){
  global $id;
  $_commnets = get_comments('post_id=' . $id);
  $comments_by_type = &separate_comments($_commnets);
  return count($comments_by_type['comment']);
}

… should actually be …

function comment_count($commentcount){
  global $id;
  $_commnets = get_comments('status=approve&post_id=' . $id);
  $comments_by_type = &separate_comments($_commnets);
  return count($comments_by_type['comment']);
}

Clear your cache (if you have it enabled) and you’ll be done.

Cheers!