Skip to content

Instantly share code, notes, and snippets.

@thomasgriffin
Last active October 13, 2015 05:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomasgriffin/2033c7a5a4a85b3c26c8 to your computer and use it in GitHub Desktop.
Save thomasgriffin/2033c7a5a4a85b3c26c8 to your computer and use it in GitHub Desktop.
<?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