There are a few ways to disable plugins on specific posts or pages while leaving it enabled everywhere else.
Two approaches to disable plugins on a single post or page
Use a plugin
The easiest way to do this, especially if you’re not a WordPress developer or engineer, would be to install one of several plugins that offer this functionality. These plugins allow you to selectively deactivate your WordPress plugins for certain post types or for individual posts and pages.
- Plugin Organizer – Plugin Organizer, by Jeff Sterup, is a powerful plugin that empowers WP administrators to disable or reorder the loading of plugins on specific pages and posts.
- WP Plugin Manager – This free plugin, by HasThemes, allows you to selectively disable any installed plugin for specified pages or posts, by simply checking a box in the WordPress editor window.
- Plugin Load Filter – This free lightweight plugin, Plugin Load Filter, by [email protected], helps filter which specific plugins should be enabled for different posts/pages in your website based on their ID’s
The more user-friendly way of disabling a plugin on specific pages or posts is to use the WordPress plugin “Plugin Organizer” by Jeff Sterup (or any similar third party plugin). We find these free plugins allow you to control where plugins are active and even assign priority levels for them – allowing different plugins to run in different order depending on what page/post you are viewing much simpler for teams with lower technical capacity.
You can also use these types of plugins if you want to temporarily enable certain plugins just on certain pages while they remain disabled site-wide.
Use a code snippet
One way to disable a WordPress plugin on specific posts or pages is by adding code snippets directly into the theme files of your site. This method requires adding some custom functions and hooking them into core WordPress functionality like “wp_head” and “template_redirect” actions.
Let’s take a look at a few of the most common approaches using snippets:
add_filter( ‘option_active_plugins’, ‘disable_specific_plugin’ );
function disable_specific_plugin($plugins){
if( $_SERVER[‘REQUEST_URI’] == ‘/shop/’ ) {
$key = array_search( ‘name_of_plugin_folder/plugin_core.php’ , $plugins );
if ( false !== $key ) unset( $plugins[$key] );
}
return $plugins;
}
This code adds a filter to the option_active_plugins hook, which runs when plugins are activated. The disable_specific_plugin function is then defined and applied to that filter, so it will run every time an active plugin is detected.
This function checks if the request URI matches “/shop/”. If it does match this URI, it searches for “name_of-plugin-folder/plugin core.php” in the list of active plugins (which was passed through as $plugins). If found, then unset removes this key from $plugins variable and returns only those remaining (effectively disabling just one specified plugin).
Even if your website is using a custom WordPress theme or using Elementor, this solution should be a good fit.
Alternatively, if you only need to select a small number of pages or posts, or perhaps just a single page or post, then this sort of custom function would probably be better suited:
<?php function disable_plugin() { if ( is_page(144) ) { deactivate_plugins('my-plugin/my-plugin.php'); } } add_action('wp', 'disable_plugin'); ?>
This custom function checks for any post or page with an ID number of 144 (you can replace this with your page or post ID number) and deactivates the plugin if it finds one. Be sure to replace the ”my-plugin.php” with the correct plugin you need to disable.
The downside of this approach is that you need to know how to find the unique IDs for each post or page, as well as understand some basic PHP coding in order to make sure everything works properly. You also will have to manually re-add any changes should they be lost when switching themes.
Final word on disabling plugins per-page or on specific posts
The easiest way to disable a WordPress plugin on a specific page or post is by using a plugin, such as Plugin Organizer. Alternatively, you can use custom code snippets that add filters and hooks into the existing WordPress core functions like “wp_head” and “template_redirect” actions.
If you’re having trouble with your layout, or seeing plugin conflicts, this all could be signs of big trouble in your WordPress website’s backend. Don’t let the problems compound, investigate these issues before they become real problems.
Our WordPress development team includes some of the most expert WP engineers in the world. Highly experienced in diagnosing complex issues with large websites, eCommerce, anything you can throw at them. They love big problems. Even if your website isn’t mission critical or huge, we’re always happy to help improve the performance of a WordPress website and to take a look at any issues your facing with your WordPress website.