2015-02-20

When you setup a wordpress theme, 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 commentor’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, its 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 then try and moderate this themselves, they turned comments off 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

We recently shifted from wordpress comments to disqus comments on WPArena, and found out that the comments on the custom post types had some issues as the previous comments on the wordpress comments 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 normal sync feature does not work due to the huge 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 this 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 disabling disqus on custom posts be sure to check your import settings first.

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.

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. 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 ( '' == get_post_type() )
5 remove_filter('comments_template', 'dsq_comments_template');
6 return $file;
7
8 }

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.
Before doing this, make a complete backup of your website and also check that you have enabled syncing between wordpress and disqus.

Image [Overheard: Word of the Day]

Related posts:

How to Create a Membership site with WordPress

Gives users the ability to comment via Facebook, Twitter, Google or WordPress IDs.

How to Exclude a Category from the Home Page

How to Convert WordPress in Your Language

How To Speed Up Your WordPress Websites Loading Times

Show more