Posts tagged with "Disqus"

Hiding Disqus Comments

Posted within Development on by Cornflower Design

While the Disqus commenting system may be fine for standard post types, sometimes clients don’t wish to use them on¬†specific custom post types. Previously (c. 2013), the following code worked for me…

add_filter( 'the_content' , 'dsq_comments_template_remove' );

function dsq_comments_template_remove( $content ) {
	global $post;

	if ( function_exists( 'dsq_comments_template' ) && 'post' != get_post_type( $post ) ) {
		remove_filter( 'comments_template', 'dsq_comments_template' );
	}
	
	return $content;
}

Now I have to use this code:

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

function dsq_comments_template_remove( $file ) {
	if ( 'question' == get_post_type() ) {
		remove_filter( 'comments_template', 'dsq_comments_template' );
	}

	return $file; 
}

Source: How to Disable Disqus on Custom Post Types in WordPress