Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
add_action( 'wp_head', 'tgm_tame_disqus_comments' );
/**
* Tames DISQUS comments so that it only outputs JS on specified
* pages in the site.
*/
function tgm_tame_disqus_comments() {
// If we are viewing a single post or page and have comments available, we need the code, so return early.
if ( is_singular( array( 'post', 'page' ) ) && comments_open() ) {
return;
}
// Tame Disqus from outputting JS on pages where comments are not available.
remove_action( 'loop_end', 'dsq_loop_end' );
remove_action( 'wp_footer', 'dsq_output_footer_comment_js' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.