Wordpress Disable Plugin on Specific Pages/Posts

Viewed 58535

Does anyone know a really effective method for disabling a plugin (that is active) on a specific page? There are some plugins that are not really needed in some pages of the website and they have lot of CSS and JavaScript files that are slowing the loading speed of the website and sometimes might conflict with other files.

I know that I can mess with the plugin's code etc. but it's not really effective.

Any ideas?

Thanks in advance!

4 Answers

Here is the idea.

 add_filter( 'option_active_plugins', 'lg_disable_cart66_plugin' );

 function lg_disable_cart66_plugin($plugins){

      if(strpos($_SERVER['REQUEST_URI'], '/store/') === FALSE && !is_admin() ) {
         $key = array_search( 'cart66/cart66.php' , $plugins );
         if ( false !== $key ) unset( $plugins[$key] );
      }

     return $plugins;
 }

p.s. Some people say you might need to put this in mu-plugins folder.

you can now use the free plugin Freesoul Deactivate Plugins to deactivate specific plugins on specific pages, posts, custom posts and archives, the settings page is really simple

Related