Why and How To Turn OFF Disqus Comments on Custom Post Types

Disable Disqus WordPress Plugin1

When you setup a WordPress site, you have the default WordPress comments system which is quite good and simple, but there are several other comments plugins which you could use for various reasons like using Commentluv, Simple Ajax Insert Comments – WordPress Plugin for giving a backlink to the commentator’s website or there is Disqus comments which is a community based comments system and shows relevant stuff from all around the Disqus network.

Why To Turn OFF Comments On WordPress Custom Post

There are different reasons why to turn off comments on some posts, however, it’s all depends on website’s benefit. For instance, Elegant Theme’s blog mention about Popular Science, decided to shut down their comments last year after finding that threads were actually able to skew perceptions of the content itself in a more negative direction. Rather than try to moderate this themselves, they turned off the comments entirely to keep a focus on their post’s content. [How To Enable, Disable And Manage Your Comments In WordPress]

How to disable Disqus on WordPress custom post types

Disable Disqus WordPress Plugin

We recently shifted from WordPress comments to disqus comments on one of our site, and found that the comments on the custom post types had some issues as the earlier comments on the WordPress commenting system were not showing up on Disqus on custom post types. An interim solution to this problem was by disabling Disqus on custom post types.

Usually, for big sites, the standard sync feature does not work due to the massive amount of comments, so instead the comment migration is to be done manually. You can do this by generating an export file and send it to Disqus to pre-import your comments. When we did exporting of comments, we only did it for posts, so custom post types were excluded, and Disqus could not fetch the comments and showed no comments. If you try to disable disqus on custom posts, be sure to check your import settings first.

Disable Disqus on CPTs

Now we are going to tell you exactly how can you disable Disqus comments on custom post types, don’t worry its quite a simple 2-minute task.

Step 1: Go to appearance tab in your WordPress dashboard and click on editor. In the editor find “functions.php” on the right side and open it.

Step 2: Just add the following code in your theme’s “functions.php” file and you’re good to go. If you change the theme, you have to edit functions.php file again.

1 // Remove Disqus from a custom post type 
2 add_filter( 'comments_template' , 'wpb_block_disqus', 1 );
3 function wpb_block_disqus($file) {
4 if ( '[highlight]custom_post_type_name[/highlight]' == get_post_type() )
5 remove_filter('comments_template', 'dsq_comments_template');
6 return $file;
8 }

Step 3: After adding this code, please make sure to change your custom_post_type_name (given in the code above on line 3) with your custom post name.

Note: Before doing this, make a complete backup of your website and check that you have enabled syncing between WordPress and disqus.

Leave a Reply

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

Sign Up for Our Newsletters

Get notified of the best deals on our WordPress themes.

You May Also Like