Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

How to Prevent Disqus from overriding your WordPress Comment Count

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Prevent Disqus from overriding your WordPress Comment Count

Disqus, a comment platform, tends to go out and change the comments number hook for WordPress. This may end up causing your theme to show the text “View Comments” instead of the actual comment count that you want it to show. The reason why Disqus tries to replace the comment count shown by WordPress is that it will be out of sync with the actual comment count on many occasions. So by having these replacement settings, your comment counts should match what they are in Disqus however getting rid of this replacement settings will make your pages load faster. Recently, we had an opportunity to work on a client’s site that had this issue ruining the styling of their comments count box. In this article, we will show you how to prevent Disqus from overriding your WordPress Comment Count in themes.

After doing a lot of search over the internet (including the GetSatisfaction forms for Disqus), we saw that most places on the web suggested that we go in the Advanced Options tab and turn on this JavaScript option for comment counts which should fix the problem. You can get to the Disqus advanced options tab by going to Comments &raquo Disqus (look on the top right corner of the screen). Refer to the image below:

Disqus Advanced Options Panel

This option will output a JavaScript in your theme’s footer. So make sure that the footer.php file actually has wp_footer(); function in there. Most themes will have that in there, but unfortunately the one we were working with did not. So we had to add it in. This will solve the issue. On every page load the text “View Comments” will show up then it will be replaced in a split second with the actual comment count. However, if you notice your page load time would get slower.

After doing further research, we ended up on Themehybrid Forums where Adam Capriola suggested an alternative. First you need to open your theme’s functions.php file and paste the following codes:

// Disqus: Prevent from replacing comment count
remove_filter('comments_number', 'dsq_comments_text');
remove_filter('get_comments_number', 'dsq_comments_number');
remove_action('loop_end', 'dsq_loop_end');

Your comment count might be off if you do this. So you should go in your Discussions setting and disable Trackbacks. Also check the boxes that says commenters must be registered and they must have a previously approved comment.

That was quite a bit of hassle to make sure that we get the right comment count number in our WordPress themes.


Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »

Comments

  1. Gabriela C says:

    Thanks! It worked!

  2. Jon Miller says:

    On my blog I am trying to link a small graphic to the #disqus_thread but about 2 seconds into the page load the graphic is overridden as a text link with comment count.

    Do you know how to fix that? Quick CSS maybe?

  3. Rakesh Suthar says:

    Hello ! sir, i added Disqus in my blog but here is a problem that total number of comments are not showing below the posts in disqus form.

    here are the screen shoot one is my blog and second is other blog where disqus is working completely.
    compare both and please solve my problem sir…
    Thanks

  4. Ari says:

    Hi, thanks for the great tip.

    I notice that the URL of the comments does not link to Disqus comments anymore after doing this. It is supposed to append “#disqus_thread” to the URL, but now simply appends the default “#comments” which does not link to the right place.

    Same goes for when there is 0 comments, it links to “#respond” which is incorrect.

    Any ideas how to fix it?

    Thanks

  5. WPBeginner Staff says:

    There could be a number of things that can prevent comments from syncing. We would suggest that you contact disqus support and they would be able to guide you better. Meanwhile also get in touch with your web host see if there are other users having similar issues with your web host.

  6. Chris-Vincent Agyapong Febiri says:

    I landed on this page because I was looking for a way to auto sync disqus comment with wordpress…The manual sync works on my site my the auto sync has refused to work, despite trying many fixes…Any suggestion?

  7. Irvan Kurniawan says:

    Thanks WPBeginner , It’s really works

  8. WPBeginner Staff says:

    Unfortunately there is no easy way to import Disqus XML export file into WordPress. It would be best if you install the official Disqus plugin in WordPress and then sync your Disqus comments with WordPress. This would mirror all your comments into your WordPress database.

  9. Mauricio Macas says:

    @wpbeginner, How to import the Disqus XML Exported Comments to WordPress? Thanks for you support.

  10. Crysislevel says:

    @wpbeginner @JasonFox thats right Jason i am using default wordpress commenting system alongwith commentluv. It is very effective! :)

  11. wpbeginner says:

    @JasonFox We did a writeup here which will tell you exactly why we like Livefyre – http://www.wpbeginner.com/plugins/what-why-and-how-tos-of-livefyre-for-wordpress/

  12. wpbeginner says:

    @JasonFox @Crysislevel He probably uses the default comment system with Comment Luv.CommentLuv lets your users pull the most recent item from their blog feed.

  13. JasonFox says:

    I am currently using Disquss and thought it does a fine job… I appreciate you sharing your trials and tribulation for our benefit. Why do you like LiveFyre better?

  14. JasonFox says:

    @Crysislevel What do you use? and could you expand on commentluv?

  15. Crysislevel says:

    thanx for the tutorial! i never use disqus because it doesn’t include commentluv which is most important in up and coming blogs. :)

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.