fbpx
Skip to Content

How To Disable A Plugin For Specific Pages And Posts

From time to time, we encounter a difficult situation where 2 plugins are in conflict. Resolving the actual conflict would require a high level of effort and you probably need a quick fix.

If the conflict is visible on one of the website pages or posts, you might want to consider disabling the plugin on just that post or page. But how do you do it?

Disabling A Plugin For Specific Pages And Posts

There is a cool code snippet I use to achieve this and it works perfectly. It is a quick and dirty fix, but it will get the job done.

You should create Must Use plugin and add this code:

add_filter( ‘option_active_plugins’, ‘disable_specific_plugin’ );
 function disable_specific_plugin($plugins){
      if( $_SERVER[‘REQUEST_URI’] == ‘/people/’ ) {
         $key = array_search( ‘name_of_plugin_folder/plugin_core.php’ , $plugins );
         if ( false !== $key ) unset( $plugins[$key] );
      }
     return $plugins;
 }

In this example, I am looking for people slug on the website. You can use something different under the if statement as well, like is_page() or is_single() to target a specific page or post you need.

It would be something like this: if ( is_page($your_page_id) )…

Be sure to try this on the staging site first and if it works, just do the same on the live site and you will be good to go.

I hope that you find this helpful. Do you have questions or want to talk more about this? Contact us!

Leave a reply:

Your email address will not be published. Required fields are marked *

Back to top