Family Encyclopedia >> Electronics

How to Disable Disqus on Custom Post Types in WordPress: A Proven Fix from WPBeginner

At WPBeginner, we recently migrated our WordPress comments to Disqus for better engagement. One issue we encountered: comments on custom post types didn't migrate smoothly. Our quick solution? Disable Disqus selectively on those post types. In this guide, we'll walk you through the process based on our real-world experience.

The problem stemmed from our site's scale—standard Disqus sync couldn't handle it, so we exported comments manually and sent them for pre-import. This worked perfectly for standard posts but skipped custom post types. That's why some pages showed zero comments despite having dozens: Disqus simply wasn't informed.

Before disabling Disqus on custom post types, double-check your import process. But if you need to turn it off for other reasons, here's how.

Video Walkthrough

Subscribe to WPBeginner

If you prefer reading or need more details, keep going.

Pro tip: Enable Disqus-WordPress sync first. And always back up your site fully before changes—we recommend tools like UpdraftPlus for reliability.

Add this code to your theme's functions.php file or a site-specific plugin:

add_filter( 'comments_template', 'wpb_block_disqus', 1 );

function wpb_block_disqus( $file ) {
    if ( 'custom_post_type_name' == get_post_type() ) {
        remove_filter( 'comments_template', 'dsq_comments_template' );
    }
    return $file;
}

Replace custom_post_type_name with your actual post type slug (e.g., 'portfolio'). This filter detects the post type and blocks the Disqus template, restoring native WordPress comments.

This fix helped us at WPBeginner—check out our related guide on preventing Disqus from overriding comment counts.