Paste the following is the code at the bottom of the your index or home page, right before the closing
<script id="dsq-count-scr" src="//EXAMPLE.disqus.com/count.js" async></script>
- Change the shortname variable from
EXAMPLEto whatever the shortname is of the forum you're using. Your shortname can also be found on your forum's Admin > Setup > Identity page.
On the index or home page, append
#disqus_threadto the end of each article URL which appears inside the href tag for the article comments link. This will tell Disqus which links to look up so it can return the correct comment count.
Example: <a href="http://example.com/article2.html#disqus_thread">Second article</a>. See Counts for non-link elements below if you're not using
Using an identifier
By default Disqus looks up the count using the comment count link's
href attribute. However, the count can also be looked up using a Disqus identifier. To do this:
Add a special attribute
data-disqus-identifier to your links.
Note: This requires having set a Disqus identifier on the comment threads themselves. Typically this is done using the
If you are unable to use Disqus identifiers with your Disqus install that's okay. By simply not adding this attribute Disqus will look up threads by their associated URLs using the
href attribute in comment count links on your site. However, since URLs can change we highly recommend using the Disqus identifier.
For the following link, Disqus will fetch the comment count by the identifier:
Example: <a href="http://example.com/article1.html#disqus_thread" data-disqus-identifier="article_1_identifier">First article</a>
Counts for non-link elements
To add comment counts to
<div> elements, add the class
disqus-comment-count as well as the attribute
<span class="disqus-comment-count" data-disqus-identifier="article_1_identifier">First article</span>
<span class="disqus-comment-count" data-disqus-url="http://example.com/article1.html">First article</span>
By default, Disqus will reload the most recent comment count with every new page load that includes
count.js is loaded, you call the following function if you'd like to poll and update the comment count dynamically:
One common use case of this function is to update elements on the page that were not available via the initial load of
Customizing comment count link text
Comment count link text can be customized at your Disqus Admin > Settings > Community page.
Example scenario: Some websites show comment counts in a small circle or square and thus remove everything but the integer from their comment count links.
Note: the comment count text customization above only applies to links on your homepage or any other page that you load count.js –– it is not possible to edit the comment count that displays above the comment embed.