-
-
Save thomasgriffin/2033c7a5a4a85b3c26c8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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