What is WP-Cli And Why You Probably Need It

Wp-Cli is a command line tool specifically made to manage your WordPress websites through the command line. By entering some simple commands you will be able to carry out tasks such as backing up, installing or updating plugins and even publishing content, without having to log in to your WordPress admin. Wp-Cli saves you time by getting rid of the need to navigate web pages to run your site and is especially useful if you are a WordPress developer or System administrator.  

In this guide, I will show you how to install Wp-Cli and how to carry out simple commands. It should be noted that in order to install Wp-Cli you will need to make sure you have a hosting account with SSH access. Other system requirements are PHP 5.3.2 or later, WordPress 3.4 or later and a Unix like environment such as Linux. We provide, and install WP-Cli for you with our hosting.

How to install Wp-Cli

Step 1. The recommended way to install Wp-Cli is by downloading the Phar build, making it executable, and placing it on your PATH. The latest version of the file can be found at https://raw.github.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Step 2. Using the cURL command type curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar This will download and extract the Wp-Cli files to your root user directory.

Step 3. Next, it’s time to set the permissions to make it executable. Enter the following command: chmod +x wp-cli.phar

Step 4. It’s best to move the Wp-Cli.phar to a folder and rename it ‘wp’. This will help you use the Wp-Cli commands just by typing ‘wp’ at the start of the commands.

That’s all there is to installing Wp-Cli! If you need more information for troubleshooting, that can be found over at https://make.wordpress.org/cli/handbook/installing/. Now, let’s jump into an overview of some simple commands we can make.

Using the Wp-Cli help system

Wp-Cli comes with a full help system. This can be accessed by typing: wp help.

Installing themes with Wp-Cli

Importing and installing themes is a lot quicker through Wp-Cli as opposed to logging in via WordPress admin and activating it. Wp-Cli connects your server directly to the WordPress theme repository allowing it to install themes in a second. Let’s use the themes ‘twenty seventeen’ as an example.

Simply type in the following command: wp theme install twentyten

Likewise, if you wanted to install the theme ‘simplicity lite’, you would just need to enter: wp theme install simplicitylite

While this will install the themes on your site it will not activate them. To do that you will need to type the command: wp theme activate twentyten

The command display when installing the Twenty Ten theme.

Installing Plugins with Wp-Cli

Just like with the themes, plugins can be installed straight from the official repository. Once again, installation is seamless and takes next to no time.

For example: wp plugin install yoastseo

The above command line will install the Yoast SEO plugin on your website. To activate it just simply type: wp plugin activate yoastseo

To deactivate any plugin just type: wp plugin deactivate yoastseo. Simple stuff!

Updating Themes, Plugins and WordPress core with Wp-Cli

Time-consuming tasks such as updating core features can be a hassle, but thankfully this can be taken care of easily through some command inputs.

To update WordPress to the latest, stable version, simply enter: wp core update

Wp-Cli will also let you update to the specific version of WordPress you want. So if you want to update to WordPress version 3.9 instead of 4.2, simply enter: wp core update — version=3.9

When it comes to updating plugins you can update all at once or just specify a single one. To update all enter: wp plugin update — all

Likewise, for a specific plugin, you should enter: wp plugin update yoastseo

This exact method applies for themes as well and would be as follows: wp theme update — all , or, wp theme update twentyten

 

If you enjoyed this article, visit our Facebook and follow us on Twitter for more WordPress related content from our Blog

 

Tagged

, ,