Add Comment and Reaction Count in Wordpress with Disqus plugin Add Comment and Reaction Count in Wordpress with Disqus plugin wordpress wordpress

Add Comment and Reaction Count in Wordpress with Disqus plugin


I've never used the wordpress plugin. But I have used the JS only version.

You can get JS only Disqus working pretty quickly by doing the following.

  1. Add this JS to your page.

    <script type="text/javascript">//<![CDATA[(function() { var links = document.getElementsByTagName('a'); var query = '?'; for(var i = 0; i < links.length; i++) { if(links[i].href.indexOf('#disqus_thread') >= 0) { query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&'; } } document.write('<script charset="utf-8" type="text/javascript" src="http://disqus.com/forums/ohu/get_num_replies.js' + query + '"></' + 'script>');})();//]]></script>

  2. Add this code to where you want the comments to display (so probably underneath the post text)

    <div id="disqus_thread"></div><script type="text/javascript" src="http://disqus.com/forums/ohu/embed.js"></script><noscript><a href="http://disqus.com/forums/ohu/?url=ref">View the discussion thread.</a></noscript><a href="http://disqus.com" class="dsq-brlink">blog comments powered by <span class="logo-disqus">Disqus</span></a>

  3. Finally - to get the comment count to show. All you need to do is append #disqus_thread to your permalink URL in any tag... so for example...

    <a href="domain.com/article">Comments</a>

would become...

<a href="domain.com/article#disqus_thread">Comments</a>

And that will replace "Comments" with x Comments... (x being the number of comments for that post).

I'm a little rusty with wordpress templates so I'm not 100% sure where you would put all of that. But if you have anymore questions I can try to help out.


I know there is a wordpress plugin for disqus. However if you want to set it up just using plain old js, disqus provides a snippet for you to use in their Universal Instructions page

http://disqus.com/comments/universal/YOURDISQUSACCOUNT

This is the comment snippet they provide

<script type="text/javascript">//<![CDATA[(function() {    var links = document.getElementsByTagName('a');    var query = '?';    for(var i = 0; i < links.length; i++) {    if(links[i].href.indexOf('#disqus_thread') >= 0) {        query += 'url' + i + '=' + encodeURIComponent(links[i].href) + '&';    }    }    document.write('<script charset="utf-8" type="text/javascript" src="http://disqus.com/forums/YOURDISQUSACCOUNT/get_num_replies.js' + query + '"></' + 'script>');})();//]]></script>

The Instructions default page is here http://disqus.com/comments/install/YOURDISQUSACCOUNT

This page is actually quite hard to get to...