How to disable Disqus on WordPress custom post types

disqus logo blue white How to disable Disqus on WordPress custom post types

UPDATE: Disqus is now up to version 2.77 and this problem still exists. But the following solution still works.

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.

The following instructions are for Disqus version 2.74 through 2.77. Later version will probably work the same.

  1. Open up the “disqus.php” file in the Disqus plugin folder (usually “/wp-content/plugins/disqus-comment-system/disqus.php”).
  2. Find line 149 and you’ll see the following.
  3. Add the following above the  if statements. (Replace “product” with your post type, or duplicate this line to address several post types.)

    So that your code looks like the following.
  4. Save and re-upload the “disqus.php” file.
  5. 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!

 How to disable Disqus on WordPress custom post types

As an award-winning podcaster, Daniel J. Lewis helps others launch and improve their own podcasts for sharing their passions. Daniel designs websites; offers one-on-one consulting; speaks on technology, social media, and theology; and Daniel hosts a network of podcasts covering how to podcast and use Audacity, clean-comedy, and the #1 unofficial podcast for ABC’s hit drama Once Upon a Time.

twitter How to disable Disqus on WordPress custom post types google plus How to disable Disqus on WordPress custom post types youtube How to disable Disqus on WordPress custom post types 

Comments

  1. RichTheRookie says

    You sir, are a life-saver! I’ve been searching all over for a way to fix this problem with Disqus.

    I tried what you did but found that this worked instead:

    Instead of “if ( ‘product’ == get_post_type() ) { return false; }”

    It should be: “if ( ‘product’ == $post->post_status ) { return false; }” with product being replaced with whatever your custom post is named.

    You see, I installed EditFlow which creates a couple of custom post-types, and as my writers would preview an article that wasn’t saved as a “Draft”, Disqus would activate, thus creating comment conflicts resulting in comments publishing on the wrong post.

    Thanks a million for pointing me in the right direction though. Much appreciated! :)

    • says

      Great!

      So you had a different goal than I did? Because your suggested code doesn’t work on the product post type from WooCommerce.

      However, maybe both your line and mine should be added.

  2. David says

    Awesome find – thank you! Just to add to the comments – if I may (to help future stragglers like me):

    It seems as if you can employ most of WordPress’ native functions to test against. I had a specific category to exclude Disqus on so:

    if (is_category( ’14′ ) ) { return false; }

    also worked

    Thank you!

  3. Onur Güven says

    is not the correct method.
    add the following code to your functions.php file inside your theme.

    add_filter( ‘comments_template’ , ‘block_disqus’, 1 );
    function block_disqus($file) {
    if ( ‘custom_post_type_name’ == get_post_type() )
    remove_filter(‘comments_template’, ‘dsq_comments_template’);
    return $file;

    }

Trackbacks

Leave a Reply

Your email address will not be published. Required fields are marked *