Managing WordPress from the Command Line with WP-CLI

Managing WordPress from the Command Line with WP-CLI. WP-CLI is the command-line interface for WordPress. You can update plugins, configure multisite installs and much more, without using a web browser. 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.

Some people fear the command line. They view it as the deep, dark ghost land of their computer, far from the familiar comforts of the GUI. A place of great mystery where even the angels fear to roam. But then there are others who appreciate the command line for what it is, a place of great power and convenient. A place where the most tedious of tasks can be performed quickly and easily, where shortcuts and scripts abound to help out the most serious of developers.

How to install wp-cli
First log into your server as root via ssh.
Download the wp-cli.phar file using wget:

$ wget -c

Next, check the Phar file to verify that it’s working:

$ php wp-cli.phar –info

To use WP-CLI from the command line by typing wp, make the file executable and move it to somewhere in your PATH. For example:

$ chmod +x wp-cli.phar
$ mv wp-cli.phar /usr/local/bin/wp

If WP-CLI was installed successfully, you should see something like this when you run wp –info:

$ wp –info

Updating WP-CLI, you can update WP-CLI with

$ wp cli update

Using WP-CLI commands
To get information about all the WP-CLI commands, run the following:

$ wp help

To check the version of WordPress your site is running, navigate to the WordPress root directory (the directory in which wp-config.php can be found)
$ wp core version

Now to upgrade your WordPress software, So you can now run the latest version of WordPress.
$ wp core update

Back up your database, just in case. wp-cli makes this just as easy by running the command
$ wp db export

To list all the plugins on your site, use the command
$ wp plugin status.

To get the list of plugins you have installed, use the command
$ wp plugin list

You want and install plugin using the following command
$ wp plugin install

To activate a plugin, run command
$ wp plugin activate

To deactivate one, run command
$ wp plugin deactivate

You wish to only upgrade a single plugin do simple command
$ wp plugin update

You can upgrade all of your plugins at once with a simple command
$ wp plugin update –all

*By substituting the word “plugin” with “theme” in the above examples, you can do the same easy maintenance of WordPress themes.

Leave a Reply

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