Enable & disable WordPress plugins from the command line

Sometimes installing or upgrading a WordPress plugin breaks both the frontend of your website and the WordPress admin too, making it impossible to disable the plugin with the user interface. If you have command line access, WP-CLI to the rescue!

Downland and install WP-CLI

Go to wp-cli.org to download and install the command line tool for managing WordPress.

List plugins

To list the WordPress plugins you have available, both active and inactive, run this:

wp plugin list

You’ll get something like this:

+---------------------------------+----------+-----------+---------+
| name                            | status   | update    | version |
+---------------------------------+----------+-----------+---------+
| akismet                         | active   | none      | 3.1.5   |
| wp-conditional-captcha          | active   | none      | 3.7.1   |
| feedburner_feedsmith_plugin_2.3 | active   | none      | 2.3.1   |
| gd-star-rating                  | inactive | none      | 1.9.17  |
| outbound-link-manager           | active   | none      | 1.11    |
| sexybookmarks                   | active   | available | 7.6.1.9 |
| tinymce-advanced                | active   | none      | 4.2.5   |
| wptouch-pro                     | active   | none      | 2.7     |
| wordpress-seo                   | active   | available | 2.3.5   |
+---------------------------------+----------+-----------+---------+

Deactivate a plugin

Let’s say you wanted to deactivate the wp-conditional-captcha plugin:

wp plugin deactivate wp-conditional-captcha

And the output:

Success: Plugin 'wp-conditional-captcha' deactivated.

To deactivate other plugins, replace wp-conditional-captcha in the command above with the plugin’s name.

Activate a plugin

And if you wanted to enable it again:

wp plugin activate wp-conditional-captcha

And the output:

Success: Plugin 'wp-conditional-captcha' activated.

Doing it directly in the database

It’s also possible to deactivate plugins directly in the database if you don’t have command line access, which I’ll cover in a future post.