UPDATE: Disqus is pushing out more updates, which would mean re-implementing this code each time. Thus, I changed methods. Thanks to Onur Güven (in the comments) for pointing out the better method.
If you have custom post types on your WordPress website and use Disqus Commenting System, you may have a need to disable Disqus in only certainly places. I'll show you how!
I created a premium WordPress plugin, Social Subscribe & Follow Icons, for adding vector social icons to blog and podcast websites. Since I podcast “how-tos” about podcasting to other podcasters (I'm a meta kind of guy), I sell this plugin on The Audacity to Podcast's website. My site uses Disqus and I sell the digital product with WooCommerce.
WooCommerce (and other ecommerce plugins for WordPress) creates custom post types and may use the default WordPress comments system for managing reviews on those products. The problem is that Disqus takes over the commenting system and now disables the WordPress system. This results in a blank Reviews tab for my products on my website.
To fix the problem, we need to tell Disqus not to run on a particular post type, and let the default WordPress system take over. In the case of WooCommerce, this custom post type is “product,” but it could be any other post type in your case.
Open your theme's functions.php file and add the following code near the bottom.
Where [crayon-5cbd68bda3546281713695-i/] is the name of your post type, like [crayon-5cbd68bda3547350393255-i/].
Now, you can update Disqus without losing your settings! Just remember to re-implement this code if you update or switch themes.
Old method (no longer recommended)
The following instructions are for Disqus version
2.74 through 2.77 2.79. Later version will probably work the same (though line numbers may change, as they did for version 2.79).
- Open up the “disqus.php” file in the Disqus plugin folder (usually “/wp-content/plugins/disqus-comment-system/disqus.php”).
- Find line
149143 (as of version 2.79) and you'll see the following.
- Add the following above the [crayon-5cbd68bda3549547413239-i/] statements. (Replace “product” with your post type, or duplicate this line to address several post types.)
So that your code looks like the following.
- Save and re-upload the “disqus.php” file.
- You may need to clear your cache.
Following these steps, Disqus will be disabled on these custom post types. In my scenario, this means I can now accept product reviews in my WooCommerce store!
I've shared this post with Disqus so that they can consider including this code in the future, or building in a function to allow users to select post types.
If this was helpful, please reshare it!