Using WP-CLI to Install, Uninstall, Enable or Disable WordPress Plugins

WP-CLI is a very powerful feature that allows you to manage your WordPress installations with SSH. 

Firstly, you will need to find out the Slug / URL of the plugin you want to manage at the WordPress plugin directory

For example, the Yoast SEO plugin uses the plugin slug of wordpress-seo, as can be seen in its URL:-

https://wordpress.org/plugins/wordpress-seo/

Then, navigate to the directory where WordPress is installed (in this case we will use public_html):-

cd public_html

Install a WordPress Plugin with WP-CLI

The SSH command to install a plugin with WP-CLI is:-

wp plugin install plugin-slug

For example, if you want to install the Yoast SEO plugin, you should run this command:-

wp plugin install wordpress-seo

Uninstall a WordPress Plugin with WP-CLI

The SSH command to uninstall a plugin with WP-CLI is:-

wp plugin uninstall plugin-slug

For example, if you want to uninstall the Yoast SEO plugin, you should run this command:-

wp plugin uninstall wordpress-seo

Disable a WordPress Plugin with WP-CLI

The SSH command to disable or deactivate a plugin with WP-CLI is:-

wp plugin deactivate plugin-slug

For example, if you want to disable or deactivate the Yoast SEO plugin, you should run this command:-

wp plugin deactivate wordpress-seo

Enable a WordPress Plugin with WP-CLI

The SSH command to enable or activate a plugin with WP-CLI is:-

wp plugin activate plugin-slug

For example, if you want to enable or activate the Yoast SEO plugin, you should run this command:-

wp plugin activate wordpress-seo

Bonus: List All WordPress Plugin with WP-CLI

The SSH command to list down all plugins and their status with WP-CLI is:-

wp plugin list

You will see a result like the following which will show the plugin’s Slug, StatusVersion and whether an Update is available:-

+------------------------+----------+--------------------+---------+
| name                   | status   | update             | version |
+------------------------+----------+--------------------+---------+
| akismet                | active   | none               | 4.1.5   |
| litespeed-cache        | active   | none               | 3.0.9   |
| wordpress-seo          | inactive | none               | 14.1    |
+------------------------+----------+--------------------+---------+