Support » Fixing WordPress » [Plugin: DISQUS Comment System] Disqus comment count at 0

  • I recently began using DISQUS and found that like many other users there were a lot of inherent issues with it playing well with WP.

    Some of the issues were based off of DISQUS’s need to insert ‘view comments’ where the comment count would normally have been in my theme. Other issues were related to the comments not showing up at all.

    I found, after a LOT of research, that most of the ‘fixes’ listed around the net aren’t updated to the most recent versions of WP. And after a lot of frustration I found that someone had managed to hack together [or at least hack out some of DISQUS’s idiocy] and get it all to play nice.

    In the interests of making your life easier and [for when it updates and I have to redo the hacks] all that, I’m posting the link I found and the coding changes you will need to make to fix it. These fixes are different from the DISQUS RSS breakage thread [closed] that is already on the forum.

    Solution found by: EVAN WONDRASEK

    Step 1: Edit the file /wp-content/plugins/disqus-comment-system/disqus.php

    Step 2: Locate the following code at line 692:

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

    Replace it with:

    function dsq_comments_number($count) {
    global $post;
    
    return $count;
    }

    ***[sic]There was no step 3 listed.***
    Step 4 (optional – this will fix comment counts in the front-end of your blog if using the comments_number() function in your theme): Locate the following code at line 697:

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

    Replace it with:

    function dsq_comments_text($comment_text) {
    global $post;
    $number_of_comments = get_comments_number();
    return $number_of_comments;
    }

    I hope this helps you avoid the hair tearing I had to go through. So far I’ve had no bad results from doing this hack.

Viewing 1 replies (of 1 total)
  • totallyspun

    (@totallyspun)

    This is the first article I’ve been able to find that attempts to address the issue I’m having, so thanks for that. Unfortunately, this solution isn’t working for me; perhaps something has changed with a subsequent version of either WP or Disqus.

    I’m using WordPress 3.3.1 and the WP Disqus plugin version 2.72. I’m attempting to show the number of comments on another page of the site in a list of articles. I used the JS solution provided by Disqus at docs.disqus.com/developers/universal/ and the link markup of

    <a href="<?php echo get_permalink(); ?>#disqus_thread" data-disqus-identifier="<?php echo get_post_meta(get_the_ID(), 'dsq_thread_id', true); ?>"></a>

    At first this was working perfectly, it changed the anchor into a span and filled the conetents with the correct # of Disqus comments; however, after a few other unrelated changes and numerous page refreshes it stopped working, leaving the anchor intact and inserting always ‘0 Comments’ regardless of the actual state.

    I have tried with manually inserting the JS code in the footer and also the option in the plugin’s advanced settings. I have tried resetting the plugin entirely but uninstalling settings on the same page.

    I have also tried the above steps — BTW step 2 is no longer necessary; the replacement code is already default in this version of the plugin’s disqus.php file — but unfortunately all it seems to do is break WP’s comments_number function, displaying only the number of comments from WP — not Disqus — and not using the provided text when using the syntax

    comments_number( '0 comments', '1 comment', '% comment' );

    I have had no luck finding any support of this issue with the disqus community, and this was the closest article anywhere I could find, so I’m hoping somebody can offer a suggestion.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: DISQUS Comment System] Disqus comment count at 0’ is closed to new replies.