最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

functions - Remove Disqus JavaScript from homepage

programmeradmin9浏览0评论

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.

发布评论

评论列表(0)

  1. 暂无评论