Forums

disqus
Comment count always shows 0 (8 posts)

  1. ChimpanzeeUK
    Member
    Posted 1 year ago #

    Since upgrading Disqus to the latest version, comments counts (at the top of the post page and on the front page listing multiple posts) all show 0.

    I had to re-apply a change I made to the original installation, changing:
    return '<span class="dsq-postid" rel="'.htmlspecialchars(dsq_identifier_for_post($post)).'">View Comments</span>'; to
    return '<span class="dsq-postid" rel="'.htmlspecialchars(dsq_identifier_for_post($post)).'">'.$comment_text.'</span>';

    in disqus.php. This worked before and doesn't appear to have changed in this update but now it's not working.

    Any ideas?

    Thanks.

  2. Chuks
    Member
    Posted 1 year ago #

    Hi,
    I had a similar problem, and just fixed it by using the code below:

    function dsq_comments_text($comment_text) {
    global $post;

    if ( dsq_can_replace() ) {
    return '<span class="dsq-postid" rel="'.htmlspecialchars(dsq_identifier_for_post($post)).'">' . $post->comment_count . '</span>';
    } else {
    return $comment_text;
    }
    }

    This works ok, i.e. displays the number of counts. However, I am getting 0 comments, event though I have several comments. I haven't found a fix to this yet. But it seems it will at least get you through your problem.

  3. noiodotnl
    Member
    Posted 1 year ago #

    Chucks' approach works, but it has the disadvantage that the comments count format is then hardcoded ie. before you could use

    comments_number('No Comments','1 Comment', '% Comments')

    Now it is simply "0","1","2", whatever arguments you give.

  4. ijohnh67
    Member
    Posted 1 year ago #

    Hello Chucks

    Hi,
    I had a similar problem, and just fixed it by using the code below:

    mind if I ask where exactly did you use this code?
    I'm just not clear.
    did you use it in "disqus.php"

    This works ok, i.e. displays the number of counts. However, I am getting 0 comments, event though I have several comments. I haven't found a fix to this yet. But it seems it will at least get you through your problem.

    I'm also having the same "0 comments" issue and was wondering if you were able to find a solution.

  5. fredeaker
    Member
    Posted 1 year ago #

    I'm also having this problem

    I'm using the Magzimus theme so, like ChimpanzeeUK, every time the plugin is updated I edit disqus.php according to the instructions here: http://blogtechguy.com/1560/fixing-view-comments-in-disqus-plugin/. Otherwise the "View Comments" link is too large for the theme.

    Any help would be appreciated.

  6. joshuahong100
    Member
    Posted 1 year ago #

    I had the same problem. There seems to be some conflict with disqus andthe function that retrieves the number of comments.

    However, you can access the global $post variable. When I checked the value, it showed the correct comment count. So, try using that comment count and bypassing any fetcher functions.

    <?php echo $post->comment_count?>
    <?php echo ($post->comment_count==1?' comment':' comments');?>

    Hope this helps.

  7. in23h
    Member
    Posted 1 year ago #

    Thanks joshuahong100! I got it to work like this:

    in disqus.php change the following:

    return '<span class="dsq-postid" rel="'.htmlspecialchars(dsq_identifier_for_post($post)).'">View Comments</span>';

    to:

    return '<span class="dsq-postid" rel="'.htmlspecialchars(dsq_identifier_for_post($post)).'">'.$post->comment_count.'</span>';

  8. gravyj
    Member
    Posted 7 months ago #

    I have used this

    function dsq_comments_text($comment_text) {
    global $post;
    
    if ( dsq_can_replace() ) {
    return '<span class="dsq-postid" rel="'.htmlspecialchars(dsq_identifier_for_post($post)).'">' . $post->comment_count . '</span>';
    } else {
    return $comment_text;
    }
    }

    but it doesn't work on my site Harv Eker. I want that the comments counts update themselves responding to the current number of comments.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags