Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Update 11/3/2014:</strong></p> <p>We now have a method for using comment counts on any element you want. The regular <a href="https://help.disqus.com/customer/portal/articles/565624" rel="noreferrer">count.js</a> script will now work if you:</p> <ul> <li>Use a <code>disqus-comment-count</code> class AND</li> <li>Use a <code>data-disqus-url</code> OR <code>data-disqus-identifier</code> attribute</li> </ul> <p>So now either of these elements would work:</p> <p><code>&lt;span class="disqus-comment-count" data-disqus-url="http://example.com/path-to-thread/"&gt; &lt;!-- Count will be inserted here --&gt; &lt;/span&gt;</code></p> <p>and</p> <p><code>&lt;span class="disqus-comment-count" data-disqus-identifier="your_disqus_identifier"&gt; &lt;!-- Count will be inserted here --&gt; &lt;/span&gt;</code></p> <p><strong>Old Answer (don't do this anymore)</strong></p> <p>The count.js script is fairly inflexible when it comes to the types of tags its looking for (it must be an <code>a</code> tag), so you'll need to use the API to accomplish this. </p> <p>This API call returns an array of thread data (you're looking for the "Posts" integer) for any number of threads that you specify: <a href="http://disqus.com/api/docs/threads/set/" rel="noreferrer">http://disqus.com/api/docs/threads/set/</a></p> <p>Because of API limits you'll ideally run this server-side and cache the counts to serve to the clients. However, unless you have a very busy site, doing it client-side is usually fine. You can email developers@disqus.com if you need more than 1000 requests/hour for your application.</p> <p><strong>EDIT</strong></p> <p>Here's a quick example of how you could do this with jQuery. This assumes that you have several empty div's that look like this:</p> <pre><code>&lt;div class="my-class" data-disqus-url="http://example.com/some-url-that-matches-disqus_url/"&gt;&lt;/div&gt; </code></pre> <p>le javascript:</p> <pre><code>$(document).ready(function () { var disqusPublicKey = "YOUR_PUBLIC_KEY"; var disqusShortname = "YOUR_SHORTNAME"; var urlArray = []; $('.my-class').each(function () { var url = $(this).attr('data-disqus-url'); urlArray.push('link:' + url); }); $('#some-button').click(function () { $.ajax({ type: 'GET', url: "https://disqus.com/api/3.0/threads/set.jsonp", data: { api_key: disqusPublicKey, forum : disqusShortname, thread : urlArray }, // URL method cache: false, dataType: 'jsonp', success: function (result) { for (var i in result.response) { var countText = " comments"; var count = result.response[i].posts; if (count == 1) countText = " comment"; $('div[data-disqus-url="' + result.response[i].link + '"]').html('&lt;h4&gt;' + count + countText + '&lt;/h4&gt;'); } } }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload