Wordpress

How to Manage WordPress Plugins from the Command Line with WP-CLI

 In this series of blog posts, we will cover the basic but useful tasks WP-CLI has to offer, such as upgrading WordPress core and managing your plugins. By the end of the series, you’ll be comfortable using WP-CLI and discovering even more ways you can use it to simplify your life! 
WP-CLI can be used to manage WordPress plugins from the command line. This is useful for scripting or automating the management of your plugins. For example, with WP-CLI you could automatically check if there is an update for your plugins and upgrade them if there is a new version.

To get information about all the WP-CLI commands related to plugins, run the following:

To get information about all the WP-CLI commands related to plugins, run the following:

[user@server]$ wp help plugin

This brings up a page similar to a main page, and shows all the commands you can use to manage WordPress plugins—including search, list, activate, and install. It is also possible to get help with a subcommand:

[user@server]$ wp help plugin 

An important start to managing your plugins is to get the list of plugins you have installed, and check what their status is. Perhaps you have a plugin installed but not activated and you need to activate it, or maybe you want to update a plugin if it has an available update. To get this information run the following:

[user@server]$ wp plugin list

What good is being able to list your plugins if you can’t manipulate them? Well, with WP-CLI you can! If you want to install a plugin, you might need to search for the name of a plugin first. You can do that with the following:

[user@server]$ wp plugin search 

For example:

[user@server]$ wp plugin search akismet

+----------------------+-------------------+--------+

| name                 | slug              | rating |

+----------------------+-------------------+--------+

| Akismet              | akismet           | 94     |

+----------------------+-------------------+--------+

WordPress + DreamHost

Our automatic updates and strong security defenses take server management off your hands so you can focus on creating a great website.

Check Out Plans

Once you’ve found the plugin you want, you can install it. The slug is a unique identifier for a plugin so that WP-CLI knows exactly which plugin you want to install. The rating field represents community votes to show how good the plugin is (this is rated out of 100, generally higher is better), but it is recommended to check reviews for the plugins online as well in the plugin directory. Copy the slug field of the plugin you want and install it using the following command:

[user@server]$ wp plugin install 

Once you have installed a new plugin, the next step to get it working is to activate it. WP-CLI makes this extremely simple as well:

[user@server]$ wp plugin activate 

WP-CLI can also deactivate plugins, which just disables the plugin; it does not uninstall it:

[user@server]$ wp plugin deactivate 

Keeping your plugins up to date is important, as it can bring new features or just improve old features with new code fixes. There are several ways to do this—First, you can upgrade all of your plugins at once with a simple command:

[user@server]$ wp plugin update --all

Or perhaps you wish to only upgrade a single plugin for some reason; you can do that with another simple command:

[user@server]$ wp plugin update 

And that’s it! Simple, right? In next week’s episode, we’ll show you how to manage your WordPress themes using WP-CLI. Stay tuned!

Have questions? Hit up our support team or tweet us @DreamHostCare on Twitter! 

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button