Deactivating WordPress plugins using deactivate_plugins function

The deactivate_plugins function in WordPress is used to deactivate one or more plugins on a WordPress site. This can be useful in situations where a plugin is causing issues or conflicts with other plugins or the WordPress core, and needs to be temporarily disabled for troubleshooting purposes.

By deactivating plugins using the deactivate_plugins function, site administrators can isolate the source of the problem and determine if the issue is caused by a specific plugin. This can help in resolving conflicts and ensuring the smooth functioning of the WordPress site.

Parameters Accepted by deactivate_plugins Function

  • $plugins (string|string[]), required. Description: Single plugin or list of plugins to deactivate.
  • $silent (bool), optional. Default value: false. Description: Prevent calling deactivation hooks.
  • $network_wide (bool|null), optional. Default value: null. Description: Whether to deactivate the plugin for all sites in the network. A value of null will deactivate plugins for both the network and the current site. Multisite only.

Return Value of deactivate_plugins Function

The function does not return a value.


How to deactivate a plugin in WordPress

Use the deactivate_plugins function to deactivate a specific plugin in WordPress.

<?php $plugin = 'plugin-folder/plugin-file.php';
deactivate_plugins( $plugin );

How to deactivate multiple plugins in WordPress

You can deactivate multiple plugins at once using the deactivate_plugins function by passing an array of plugin file paths.

$plugins = array(
deactivate_plugins( $plugins );

How to deactivate a plugin conditionally in WordPress

Use the deactivate_plugins function within a conditional statement to deactivate a plugin based on a certain condition.

<?php if ( $some_condition ) {
 $plugin = 'plugin-folder/plugin-file.php';
 deactivate_plugins( $plugin );


In conclusion, the deactivate_plugins function is a valuable utility for managing and deactivating plugins in WordPress. By using this function, developers can easily deactivate multiple plugins at once, saving time and effort. It provides a convenient way to streamline the plugin management process and ensure a smooth user experience. However, it’s important to use this function with caution and to thoroughly test any changes before deploying them to a live site. With proper use and testing, the deactivate_plugins function can be a valuable asset for WordPress developers.

Related WordPress Functions