Family Encyclopedia >> Electronics

How to disable Disqus in custom post types in WordPress

We recently switched WordPress comments to the Disqus commenting system on WPBeginner. One of our users pointed out that the comments in our custom post types did not migrate correctly. For a temporary fix, we simply disable Disqus on certain custom post types. In this article, we will show you how to disable Disqus on custom post types in WordPress.

Disqus not displaying comments in our custom post types was a mistake on our part. When importing comments to Disqus, we were unable to use the normal sync feature due to the size of our site. We had to generate an export file and send it to Disqus to pre-import the comments. This means that we only did this for posts and not for other post types. So when Disqus showed 0 comments on a custom post type item that had more than 50 comments, it was really because Disqus didn't know it had any comments because we didn't tell Disqus.

In other words, if you were going to disable Disqus on custom post types because it wasn't working, maybe you should check your import settings first. But if you want to disable Disqus on custom post types for some other reason, then go ahead.

Video Walkthrough

Subscribe to WPBeginner

If you don't like the video or need more instructions, continue reading.

Before making any changes, make sure you have enabled sync between Disqus and WordPress. It is also recommended that you always take a full WordPress backup of your site before making any major changes.

When you're ready, simply add this code to your theme's functions.php file or a site-specific plugin.

 add_filter ('comments_template', 'wpb_block_disqus', 1); función wpb_block_disqus ($ archivo) if ('custom_post_type_name' == get_post_type ()) remove_filter ('comments_template', 'dsq_comments_template'); devuelve $ archivo; 

Don't forget to replace custom_post_type_name with the name of your custom post type. This code simply adds a filter to check for a specific custom post type and disable display of the Disqus comment template.

We hope this article helped you to disable Disqus in custom post types in WordPress. You can also see how we prevent Disqus from overriding the comment count in WordPress.

If you liked this article, please subscribe to our YouTube channel or join us on Twitter and Google+.