Support Forum

Comment count in posts is wrong

22 Answers

New Answer

YS Yellow Swordfish
Yellow Swordfish
Member

Back to the image. Do you have a right image? How is it wrong?

SO SoWhat
SoWhat
Member

Now image is correct. In print screen you see 2 comments, but upper is written “3 comments”

YS Yellow Swordfish
Yellow Swordfish
Member

And what are these two comments? Are they genuine comments created in th blog? Or do they come from the forum topic?

SO SoWhat
SoWhat
Member

they were created when comment sinchronising was on from WP post. So they are genuine.

YS Yellow Swordfish
Yellow Swordfish
Member

Curious. All that does is retrieve the count from WP itself. Oh well.
Something seems to have gone adrift with linking and I suspect it has much to do with post revisions (which are a royal pain in the backside for anyone trying to write plugins in this area) and maybe the Trash as well.
I will add this to the list!

SO SoWhat
SoWhat
Member

it doesn’t matter if post revisions are enabled or disabled.

If you set $blogcomments to TRUE, then first LINKED comment is counted as 2. All next comments are counted as one, so we always get comment count +1.

Maybe this is not the best solution, but atleast it works:

 

function sf_comments_number($no_comment=”0 Comments”, $one_comment=”1 Comment”, $many_comment=”% Comments”, $blogcomments=false)
{
    global $wp_query;

    sf_initialise_globals();

    $result = $no_comment;
    $total = 0;
    $postid = $wp_query->post->ID;
    $links = sf_blog_links_control(‘read’, $postid);

    # If linked get the post count (-1 of course)
    if ($links && sf_can_view_forum($links->forum_id))
    {
        # link found for this post
        $total = (sf_get_posts_count_in_topic($links->topic_id) -1);
        if ($total >0) $total=$total-1;
    }

    # If to include standard blog comments add that number
    if($blogcomments)
    {
        $total = ($total + $wp_query->post->comment_count);
    }

    if($total > 0)
    {
        if($total == 1 ? $result=$one_comment : $result=str_replace(‘%’, $total, $many_comment));
    }
    echo $result;

    return;
}

 

YS Yellow Swordfish
Yellow Swordfish
Member

I don’t follow your argument and most definitely do not agree that this happens. Not on any of my tests does it happen.
However, there IS (in 4.2) a problem with the count if a forum post is awaitng approval as it gets included when it should not. Mayvbe that s where your extra one s coming from.
This is fixed in 4.2.1

SO SoWhat
SoWhat
Member

no, comment approval is turned off. Also Akisment plugin is disabled.