admin管理员组

文章数量:1402086

Hey WordPress friends,

I’m using the Disqus comment system plugin, which is working fine. My homepage is just a collection if recent posts and therefore not having the option to leave a comment (as desired).

Unfortunately, I still see that the Disqus plugin is rendering JavaScript output within the homepage and would like to get rid of this.

I've Tried the following but without luck. Any help is appreciated! Thanks

function block_disqus_count() {
if ( is_front_page())
    remove_filter('output_count_js', 'dsq_output_count_js');
}

add_action( 'block_disqus_count' , 'block_disqus_count');

Hey WordPress friends,

I’m using the Disqus comment system plugin, which is working fine. My homepage is just a collection if recent posts and therefore not having the option to leave a comment (as desired).

Unfortunately, I still see that the Disqus plugin is rendering JavaScript output within the homepage and would like to get rid of this.

I've Tried the following but without luck. Any help is appreciated! Thanks

function block_disqus_count() {
if ( is_front_page())
    remove_filter('output_count_js', 'dsq_output_count_js');
}

add_action( 'block_disqus_count' , 'block_disqus_count');
Share Improve this question asked Jul 22, 2016 at 3:10 Kevin BronsdijkKevin Bronsdijk 1 3
  • 1 Plugins are off-topic here... lo ciento mi amigo. – jgraup Commented Jul 22, 2016 at 4:07
  • Hi Kevin, welcome to WPSE. As @jgraup says - you'll need to ask this at the Disqus forums, sorry! – Tim Malone Commented Jul 22, 2016 at 4:53
  • That's fine. It can be seen as a general WP programming question. I 'm just trying to overwrite / suppress the call of a plugin, which isn't working. – Kevin Bronsdijk Commented Jul 22, 2016 at 4:55
Add a comment  | 

2 Answers 2

Reset to default 1

You should deregister it. Add this function into your functions.php:

add_action( 'wp_enqueue_scripts', 'disqus_scripts' );

function disqus_scripts() {
  if(is_front_page()) {
    wp_deregister_script('disqus_count');
  }
}

Solved it by altering the file disqus.php. First find function

function dsq_output_count_js() {

Add the following check before the function tries to output the JS

 if ( ! is_front_page() ) { ?> <script type="text/javascript"> 

I’m using this until Disqus created the option to configure this. Thanks for the help.

本文标签: functionsRemove Disqus JavaScript from homepage