X

Stop Disqus from outputting JS on anything but single posts or pages

Ronneby Gallery

Disqus outputting JS on parts of your wordpress website you don't want? Adding this snippet to the functions.php of your wordpress theme will only output JS on is_singular posts or pages where comments are available.



Code Snippet:


add_action( 'wp_head', 'tgm_tame_disqus_comments' );
function tgm_tame_disqus_comments() {
if ( is_singular( array( 'post', 'page' ) ) && comments_open() )
return;

remove_action( 'loop_end', 'dsq_loop_end' );
remove_action( 'wp_footer', 'dsq_output_footer_comment_js' );
}

Comments  Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!