My final post for 2009 should probably have been more climactic. If I had planned it right, the Death in the Digital Age post should have been my last for this year. Oh well.

I mentioned in a previous post that I was switching the comments system on Snipe.Net to Disqus, and although I’ve been overall quite happy with the changeover, one issue that frustrating to me is that the comment count on the site’s homepage, category pages, and individual blog post pages (single.php) was kinda fux0red.

On the homepage, it displayed “x comments and y reactions” which made the text too long for the carefully crafted masking tape strip meant to contain them. On the blog post article pages, it shows “Comments”, omitting the comment count altogether.

I found a way to fix it, and the site that contained part one of the fix is now unavailable, I figured I’d post it here in case anyone needs it:

Around line 275 of the DISQUS plugin in disqus.php (accessible via dashboard – plugins – editor), you’ll see the following:

} else if ( (is_single() || is_page() || $withcomments || is_feed()) ) {

change this line to:

} else if ( (is_page() || $withcomments || is_feed()) ) {

When I did this, I was then seeing duplicate “X Comments”, one from WordPress and one from Disqus – in other words, the page was displaying both the WordPress version and the Disqus version, but taking out the WP Comments counter in the single.php removed the code Disqus was replacing, so I ended up with no comments.

The solution for me was to add style=”display: none” to the WordPress comments part of the single.php file, so it looks like this:

<a href="#disqus_thread" style="display: none;">< ?php comments_number('0 Comments', '1 Comment', '% Comments', 'number'); ?></a>

If your comment counter is still showing “and x reactions”, there is a way to fix this too, although it kind of sucks. In your Disqus control panel, in SETTINGS in the CUSTOMIZE tab, you have to remove the template text that is in place for the Reactions section:

The reason this sucks is because by removing the template text here, it also removes the number count text from the Reactions section below the comments block on the article pages, as you can see in my comments block below. It still shows a “Reactions” header, but instead of showing “34 Reactions”, it leaves off the running tally of reactions to the post. I don’t know of a workaround for this yet, but it’s what I had to do to get the comment counter to fit on the tiny masking tape design again.

This leaves the text in the source, so the Disqus Javascript can successfully replace it with it’s own comment counter, but hides it from displaying to the user.

Hope that helps – happy new year 🙂

Advertisement

468x60_makemoney

Advertisement

Themeforest
Previous post

Final Fail of the Year

Set Facebook Lite as your default in your settings
Next post

Unclutter Your Facebook Feed: Set FB Lite As Your Default

snipe

snipe

I’m a tech geek/dev/infosec-nerd/scuba diver/blacksmith/sword-fighter/crime fighter/ENTP/warcrafter/activist. I'm the CTO at Mass Mosaic and the CEO of Grokability, Inc. in San Diego, CA. Tweet at me @snipeyhead or read more...

  • Glad you found the code to fix for your template =)

  • Hi Giannii – I did, sort of. When I modify the code, the reaction count still shows unless I remove the template text in the Disqus admin (I added a screenshot to this post, back up in the main body of the post). By doing that, it drops the tally on the reactions in the comments box area. Is there any kind of workaround? (In other words, if I want the reaction count to be hidden in the index pages and small masking tape area that is only big enough for the comments count, I have to take it out of the template – and when I do that, the number of reactions isn't displayed below my comments anymore.)

  • Thank you for the tip, I have this exact problem. Your solution is working fine on my test-site, so Disqus will go live on my main site in a few days (hopefully everything will go smooth).

    You have an excellent blog by the way, like it very much.

  • Hi Eddie – so glad it helped – and thanks for the kind words! 🙂

  • axecrea
  • Thanks for sharing

  • Superb, worked great, many thanks!

  • Thank you!
    worked great fo me.

  • hadleybishop

    Hi, Glad to see this post I hope,I will see your next post soon.

  • robertdc554

    what a great article, thanks for publishing this. will read more from you many thanks!

  • Thanks for the information.

  • Hello,
    actually I cannot find the right line, I have only this one: if ( get_option(‘disqus_cc_fix’) == ‘1’ || !count($query->posts) || is_single() || is_page() || is_feed() ) { return

    Can you help me solve this issue?=

  • i did have same issues. thanks for the info

  • Just looking for this problem in one of my blog, thanks for your quick fix and suggestions !

  • Thanks alot for your help 🙂 this worked

  • Thanks for the tutorial

  • I had the same issues. There seems to be some conflict with disqus and the function that retrieves the number of comments.

  • Thanks! Late to the party here, but thanks all the same 🙂