How to Selectively Disable Plugins in WordPress – 2026

Last updated on August 2nd, 2024 at 12:35 pm

Managing a WordPress website often involves juggling multiple plugins to achieve the desired functionality. However, running too many plugins can slow down your site. In some cases, you might want to selectively disable certain plugins on specific pages or posts to improve performance. This guide will show you how to selectively disable plugins in WordPress without using additional plugins. By doing so, you can enhance your site’s speed and user experience.

Why Selectively Disable Plugins?

  1. Improve Performance: Reduce page load times by disabling unnecessary plugins on specific pages.
  2. Increase Security: Minimise the risk of conflicts and security vulnerabilities.
  3. Enhance User Experience: Ensure a smoother and faster browsing experience for your visitors.

Step 1: Upload a child theme

To add the code snippets directly to your theme’s functions.php file you will need a child theme installed. If you do not have a child theme installed you can use our free child theme generator. Once you have created the child theme, you will need to upload it.

  1. Go to Themes > Add New.
  2. Click “Upload Theme”.
  3. Install and activate the child theme.

Step 2: Add Code to Disable Plugins

To selectively disable plugins, you’ll need to add custom code that checks the current page or post and disables plugins accordingly. Add the following code snippet:

/*
 * Snippet: How to Selectively Disable Plugins in WordPress – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1330
* Tested with WooCommerce 10.7.0
* "Selectively disable plugins on specific pages"
*/ function wcsuccess_disable_plugins_on_specific_pages($plugins) { // List of plugin filenames to disable $plugins_to_disable = array( 'plugin-folder/plugin-file.php', // Replace with actual plugin folder and file name 'another-plugin-folder/another-plugin-file.php', ); // Get the current page ID $current_page_id = get_queried_object_id(); // Disable plugins on the homepage if (is_front_page()) { foreach ($plugins_to_disable as $plugin) { if (in_array($plugin, $plugins)) { unset($plugins[array_search($plugin, $plugins)]); } } } // Disable plugins on a specific page (e.g., page ID 123) if ($current_page_id == 123) { foreach ($plugins_to_disable as $plugin) { if (in_array($plugin, $plugins)) { unset($plugins[array_search($plugin, $plugins)]); } } } return $plugins; } add_filter('option_active_plugins', 'wcsuccess_disable_plugins_on_specific_pages');

Step 3: Identify Plugin Filenames

To correctly disable a plugin, you need to know its folder and filename. You can find this information in the plugin’s directory. For example, if the plugin is located at wp-content/plugins/plugin-folder/plugin-file.php, you would use plugin-folder/plugin-file.php in the code snippet.

See also  How to Create an Exit Popup Without a Plugin in WooCommerce - 2026

Step 4: Customise for Different Conditions

You can customise the code to disable plugins under various conditions, such as on specific post types, categories, or templates. Here are a few examples:

  • Disable Plugins on Posts:
/*
 * Snippet: How to Selectively Disable Plugins in WordPress – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1330
* Tested with WooCommerce 10.7.0
* "Disable plugins on posts"
*/ if (is_single()) { foreach ($plugins_to_disable as $plugin) { if (in_array($plugin, $plugins)) { unset($plugins[array_search($plugin, $plugins)]); } } }

Disable Plugins on Category Pages:

/*
 * Snippet: How to Selectively Disable Plugins in WordPress – 2026
* Author: John Cook
* URL: https://wcsuccessacademy.com/?p=1330
* Tested with WooCommerce 10.7.0
* "Disable plugins on category pages"
*/ if (is_category('your-category-slug')) { foreach ($plugins_to_disable as $plugin) { if (in_array($plugin, $plugins)) { unset($plugins[array_search($plugin, $plugins)]); } } }

Use Cases for Selectively Disabling Plugins

  1. Optimise Homepage Speed: Disable heavy plugins on the homepage to improve load times.
  2. Focus on Landing Pages: Disable unnecessary plugins on landing pages to ensure they load quickly and provide a seamless user experience.
  3. Simplify Checkout Process: Disable plugins during the checkout process to reduce potential conflicts and speed up transactions.
  4. Streamline Blog Posts: Disable social sharing or other non-essential plugins on blog posts for faster loading.
  5. Enhance Mobile Performance: Disable certain plugins when a user accesses the site from a mobile device to ensure optimal performance.
See also  How to Integrate Cloudflare with Your WooCommerce Store: A Step-by-Step Guide

Conclusion

By selectively disabling plugins in WordPress, you can significantly enhance your site’s performance and user experience. The method described above allows you to control which plugins are active on specific pages, posts, or conditions without relying on additional plugins. Implementing this strategy can lead to faster page load times, reduced conflicts, and a more streamlined website.

0 0 votes
Article Rating

Stay In Touch

Was this post helpful? Why not show your support and buy me a coffee?

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Scroll to Top
0
Would love your thoughts, please comment.x
()
x
×