开发者

Add Comment and Reaction Count in Wordpress with Disqus plugin

Okay I'm trying to add comments and reactions count just like what you would normally see on some wordpress blogs like http://johntwang.com/blog/ where开发者_StackOverflow社区 on the left top of each post there is ** comment and * reactions*

Add Comment and Reaction Count in Wordpress with Disqus plugin

(source: windows7hacker.com)

My problem is I can't find the disqus's documentation, where hopefully there is some method I can call to return me the number of reactions and comments. Also if I use the wordpress default method

<?php comments_popup_link ('zero','one','more','CSSclass','none');?> 

it only displays "Comments" not even the comment's number count on the main page.

How can I add reaction and comment count with disqus plugin ?

edit:

well my site is http://www.windows7hacker.com/ I don't know how I suppose to add comments count at first place. But right now if I use the wordpress method, it will return me only comments, which is exactlly one of the problem they have described in their help page

Add Comment and Reaction Count in Wordpress with Disqus plugin

(source: windows7hacker.com)

I've tired to check the comment count option still doesn't work :(


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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜