2 Killer Disqus Tricks for Your WordPress Site

If you have a self-hosted WordPress site or blog, you surely must have faced the consistently annoying Spam problem. These are basically automated programs -bots – from all kind of companies including apparel brands, SEO companies etc. that keep filling up and submitting comments on your articles.

In my opinion, the best way to combat WordPress comment spam and at the same time make commenting easier, faster and interactive for your users is installing the Disqus Commenting System.

Now like me, if you too have custom post types like Portfolio or Woocommerce products etc. you should manually install Disqus on your site using their Universal code instead of using their standard WordPress Disqus plugin. Because with the plugin, Disqus comments appear only on pages that have comments by default in your theme, which is usually only your blog posts. Whereas with the code you can add Disqus comments wherever the hell you want!

For example, Woocommerce converts the WP comment system to ‘Reviews’ on single product pages. I wanted Reviews but I also wanted visitors to be able to just comment on my products. So I added the Disqus universal code to content-single-product.php found inside the plugin’s templates folder. I also added the code to my single-portfolio.php so that Disqus comments would show up on my portfolio items.

How to Install:

You can log in to your Disqus account and under the ‘Install’ option, select ‘Universal code’. Copy this code and place it on any page you want (and wherever you want it on that page) using a child theme.

Now once you have successfully installed Disqus, the following tricks will help you make the most of this awesome commenting system.

1. Block WordPress Comments

Even after installing Disqus, you’ll notice that you’re still getting spam comments through your regular WordPress commenting system even though you can see neither the commenting form nor the comments submitted on your site. All you see is Disqus comments however, the native WordPress comment system is STILL there, just hidden. But obviously not hidden from bots. So you need to block it.

To do that, paste the following code snippet in your child theme’s functions.php file

/* block non-disqus WP comments */
add_action('pre_comment_on_post', 'block_wp_comments');
function block_wp_comments() {
wp_die( __('Sorry, comments are closed for this item.') ); }

That’s it. You’ll no longer receive spam from WP comments and can enjoy the spam-free environment of Disqus.

2. Make Disqus work with Your Ajax Site

If yours is an Ajax site (usually true if you see transitions when you click on different links on your website), Disqus will not work for you out-of-the-box.

You’ll need to paste the following additional code before the closing script tag in the code you have copied from Disqus already.

/* * * Disqus Reset Function * * */
var reset = function (newIdentifier, newUrl, newTitle, newLanguage) {
reload: true,
config: function () {
this.page.identifier = newIdentifier;
this.page.url = newUrl;
this.page.title = newTitle;
this.language = newLanguage;

Refresh your page to see Disqus working on your posts.

Need Help?

Are there any other Disqus issues you have or have been looking for an answer to?
Let me know and I might just be able help 🙂