Are You Frustrated With Your Blog Or Website?

Do you want to start a blog but don't know how? Let me show you! Or do you have a blog that you want to do more with? Let me help! Is all your time taken up with maintenance and you wish you could concentrate on the writing? Let me reclaim your time!

Fixing View Comments in Disqus Plugin

I’ve made no secret of the fact I love the Disqus commenting system plugin. However each time I upgrade it I have to go through the same rigmarole of changing the plugin due to one specific problem. So this will explain how I fix the View Comments problem in the Disqus plugin for WordPress.

The Problem

On my Blog page the comment count works fine, as you can see in this picture:

The 44 text is displaying perfectly on the Blog, category and archive pages. However on the single post page by default instead of the comment count it says View Comments and is cut off, as you can see below.

So to fix this (or at least change it to the way I prefer, as some people may prefer it saying View Comments), inside the wp-content/plugins/disqus-comment-system folder you need to edit the disqus.php file. For those not comfortable doing this, make a backup or you can always re-install a new copy of the plugin if things go wrong. On line 485 you will see this section of code:

if ( dsq_can_replace() ) {
return ‘<span class="dsq-postid-’.$post->ID.‘">View Comments</span>’;
} else {

It’s the View Comments wording here that is displaying. Luckily we can easily change this to the comment count by simply exchanging View Comments with ‘.$comment_text.’.

if ( dsq_can_replace() ) {
return ‘<span class="dsq-postid-’.$post->ID.‘">’.$comment_text.‘</span>’;
} else {

So once done, my single post page now looks correct, displaying the number of comments:

There, looks lovely again. This isn’t really a bug as it’s designed to say View Comments there, however in the default WordPress comment system this would show the number of comments here, so we are simply re-creating that functionality.

Subscribe to My Newsletter
Income Blogging Guide Blueprint Get your FREE
95 Page
Income Blogging Guide Blueprint when you subscribe today!
Name: 
Email: 
 
  • http://www.newwaveclassics.fm/ Rich

    Hi Joel,

    I was wondering if you have ever seen a problem like I'm having on http://www.newwaveclassics.fm? If you look at the main page and the individual posts, you can see the number of comments shifted dramatically to the right of the comment bubble. I found your blog by searching on span.dsq-postid because that appears to hold the key to my display problem.

    If I turn off Disqus it displays perfectly. There is something about the Disqus plugin that is adding additional padding and I have not been able to find the answer.

    Any ideas?

    Thanks,

    Rich

  • http://blogtechguy.com/ Joel Williams

    Interesting Rich, I had a look in Chrome and IE8 and it looks like it's displaying fine for me. The number of comments is just to the right of the bubble, or it says View Comments on the single post page. That's how it's supposed to be isn't it, just next to the bubble like the date is next to the clock and the author name next to the other icon?
    Is it a different browser you can see the problem on?

  • http://www.newwaveclassics.fm/ Rich

    Thanks for the reply Joel. I was able to narrow it down with the help of a friend and added some CSS that fixed it. Thanks for looking. I would have replied back but I was working on another display problem. :)

  • http://blogtechguy.com/ Joel Williams

    Glad you got it sorted out!

  • http://www.viking-direct.org/office-supplies.html Office Supplies

    Looks perfect. Thanks for sharing. Glad everything is now sorted out.

  • http://brian.se/ Brian Einarsen

    I have a similar issue but in my case the comment thread permalink at the top of the page is not showing the correct comment count. Here is an example post:
    http://brian.se/telenor-lurade-mig-stal-mina-pe...

    Any ideas of a solution?

  • http://blogtechguy.com/ Joel Williams

    I haven't seen that problem before Brian. I have changed some settings in Disqus too but I know it works fine in Thesis as I do use it for quite a few of my clients.
    If you go into your Disqus settings, click Customize on the left and then the Appearance tab, under Comment Count link you should have a {num} (or {num} comments) in for Multiple Comments. Are those boxes set up correctly?

  • http://brian.se/ Brian Einarsen

    Thanks for your quick reply Joel.
    Yes they're correct, I just translated the “comments” into Swedish, {num} is still there.

    I contacted Disqus and they told me the following (which I don't really get):
    On your page, at the top of all the posts it says “(x) KOMMENTARER AND (x) REAKTIONER” – which is the correct text. But at the bottom it will say “1 KOMMENTARER” which is the incorrect count. This only happens with certain WordPress themes which are written differently than they're supposed to. To fix this, you will have to go into your theme's code and remove the code which shows the comment count at the bottom of the post.

  • http://abisso.org nolith

    Very useful, thank you.

  • http://blogtechguy.com/ Joel Williams

    Strange, as I've used it in Thesis a lot and it has always been fine for me. Also the answer doesn't make much sense because at the top is the correct text but incorrect count and at the bottom is the correct count.
    You could try removing that info from the byline and then using the Thesis Openhook plugin adding in <?php comments_number('0 KOMMENTARER', '1 KOMMENTARER', '% KOMMENTARER'); ?> somewhere and seeing if that displays the correct count. If so you can then position and style it the way you like.

  • http://brian.se/ Brian Einarsen

    Exactly.

    That sounds like a plan, I'll try that.

    Thank you so much for your time!

  • http://blogtechguy.com/ Joel Williams

    Brian – also try this: http://help.disqus.com/entries/102528-wordpress... the section on Comment Count on permalinks – if you go to Disqus in WordPress (under Comments) and then top right click Advanced Options, the option is there. Just fixed the same problem for another client.

  • http://brian.se/ Brian Einarsen

    Thank you so much! As it seems, this actually solved the problem. I thought this feature only was for dealing with the Disqus comment count – which was working fine – and not the WP/Thesis comment count.

  • http://blogtechguy.com/ Joel Williams

    Great, I think it's the order or including the javascript that makes the difference for whatever reason.

  • http://www.laptopbatteriesinc.com.au/ Australia Battery inc

    We supply electronic products with good quality and low price.Especially our Laptop Battery have a long life.we sell many kinds of branded merchandise.such as apple Laptop Battery /ibm Laptop Battery…… Please contact us to know details.I'm sorry if i bothered you.I hope you can forgive me.

  • http://www.canedesign.com SEO Miami

    I have seen such problem. I have changed some settings in Disqus too but I know it works fine in Thesis as I do use it for quite a few of my clients.

  • http://blogtechguy.com/ Joel Williams

    Thanks for letting me know!

  • http://www.laptopbatteriesinc.com.au/ laptop battery

    this was a really good article. thanks for sharing the information.DISQUS allows the blogger to have greater control with comments.powerful and convenient

  • ongamesite

    Hi every friends,

    Welcome to Flash Games, the online games resource website. Free arcade games Play on 4000 games,Nice Video and counting . The best of online games is on http://www.ongamesite.com.We have fun playing some of the best online games ever created and remember to check back often because we are always adding new games.

    Good luck.

  • ongamesite

    good

  • http://iphoneawareness.com/firmware/ iphone firmware

    thanks for posting this, was really useful and interesting to me

  • http://www.dyc-media.nl Edward Hendriks

    Thnx mate, I needed this!

  • http://www.articlesbase.com/vision-articles/tej-kohli-foundation-cornea-transplant-mission-2669752.html Tej Kohli

    Some time buddy you Know CSS error and server error make my Blog Down

  • http://twitter.com/testvikrant Vikrant Suman

    test

  • http://magaluf.senorstag.com/indexmag/13000/magaluf_stag_weekends.htm magaluf stag

    This only happens with certain WordPress themes which are written differently than they're supposed to. To fix this, you will have to go into your theme's code and remove the code which shows the comment count at the bottom of the post….

  • http://www.suitusa.com/ man suit

    yeah right, spammer! need you to be removed!

  • http://www.suitusa.com/ Mens Suit

    yes.. your comments can be posted through twitter because it was itegrated.

  • http://beerpla.net Artem Russakovskii

    I don’t understand what the heck the point of this code in the plugin was at all.

    If you look at the plugin code, it sets disqus_replace=all if it finds a valid DISQUS API key (which is part of setting up the plugin).

    Then, later on it checks if disqus_replace==all and if so, always returns “View Comments” and breaks formatting of things like small comment count boxes like I have on http://www.androidpolice.com

    What the heck is going on…

  • http://beerpla.net Artem Russakovskii

    OK, I think I get what they’re trying to do (which is mark a certain area of the html as replaceable by JS with the proper comment count later). However, the fact that the “View Comments” text link is not configurable is just shocking, at this level of supposed maturity of DISQUS.

    I’ll try pinging them about this thread, as what the plugin does is ridiculous.

  • http://blogtechguy.com/ Joel Williams

    It surprised me immensely to see the words hardcoded in there! It would be easy to replace with a variable and not break custom formatting of count counts, I agree. Thanks Artem.

  • http://socialsubmit.info social bookmarking service

    you can see the number of comments shifted dramatically to the right of the comment bubble.This only happens with certain WordPress themes which are written differently than they’re supposed to. To fix this, you will have to go into your theme’s code and remove the code which shows the comment count at the bottom of the post.

blog comments powered by Disqus
Joel Williams

Joel Williams

Blog Tech Guy

Taking care of the
technical side of blogging!