disable active plugins for specific theme

What @Sumit says in the comments (and you found out for yourself) is correct. If you deactivate a plugin in a theme it is deactivated permanently, until it is activated again.

Also, if you attach your deactivation action to wp_head it is executed at every pageload, which is not necessary. What you need to do is deactivate the plugin when the theme is activated, and reactivate the plugin when another theme is activated. There are action hooks for this: after_switch_theme on activation and switch_theme on deactivation. So you would have:

add_action('after_switch_theme','disable_plugins');
add_action('switch_theme','enable_plugins');

You already have the disable_plugins function, the other one you’ll need to write yourself.

Leave a Comment