Skip to content

Safely deactivating a WordPress plugin from the command line

When wp-admin is down, the right way to disable a misbehaving WordPress plugin is via WP-CLI — not by renaming directories. Here is the procedure that preserves hooks.

A plugin update is keeping wp-admin from loading. The dashboard returns a 500 or hangs. You need to disable the plugin to get back in, but the common advice — SSH in and rename wp-content/plugins/<plugin> — leaves transients, scheduled tasks, and option flags in inconsistent states. Worst case, the plugin’s deactivation hook never runs, and reactivating later runs an upgrade routine against half-cleaned data.

What’s actually happening

WordPress tracks the active plugin list in the wp_options table under the key active_plugins (and active_sitewide_plugins on multisite). Renaming the directory removes the code path but leaves the option entry pointing at the missing file. WordPress will silently skip it on load, but the plugin’s deactivation_hook callback never fires — so cron jobs, capabilities it registered, and database state changes it would normally roll back stay in place. WP-CLI calls the same deactivation path the dashboard would.

How to verify

First, confirm which plugin is the culprit. SSH in and check recent PHP errors:

tail -n 100 ~/logs/example.com.php.error.log

The fatal will name the file. Then list active plugins via CLI:

wp plugin list --status=active --format=table --path=/home/user/public_html

Note the slug — that is what you’ll pass to deactivate.

The fix

Deactivate with the real hook firing:

wp plugin deactivate <plugin-slug> --path=/home/user/public_html

On multisite where the plugin is network-activated:

wp plugin deactivate <plugin-slug> --network --path=/home/user/public_html

If WP-CLI itself can’t bootstrap because the fatal happens during plugin load, skip the offending plugin during the bootstrap so the rest of WordPress can boot:

wp plugin deactivate <plugin-slug> --skip-plugins=<plugin-slug> --path=/home/user/public_html

After deactivation:

  1. Verify wp-admin loads.
  2. Check that scheduled events the plugin owned were cleared: wp cron event list --path=/home/user/public_html | grep <plugin>. Stale events keep firing fatals.
  3. Check for orphaned options if the plugin documented any: wp option list --search="<prefix>*" --path=/home/user/public_html.

Renaming the directory is reserved for the case where the deactivation hook itself is the fatal — and even then, follow with wp option update active_plugins to clean the list explicitly.

Stack Harbor’s on-call rotation runs this exact path on Sev-1 plugin incidents; the runbook lives in Deployment Management.