Speeding up your development process should be one of your top priorities. Simply put, if you do more work in less time, then you will have more time to work on more projects, study and rest.
WP-CLI is one of the command line tools specifically made to manage your WordPress websites through the command line. With a few simple commands, you can manage WordPress without even needing to login to your WordPress admin and navigate through the pages.
In this tutorial, we’re going to learn exactly what WP-CLI is, how to install it and an overview of the basic commands of this tool.
WP-CLI will be particularly useful if you are a WordPress developer, System Administrator or run a business built around WordPress. This command line tool will greatly help you do more in less time. For example, taking backups, updating WordPress and plugins, publishing content and querying databases can be accomplished relatively quickly.
Requirements of WP-CLI
To install WP-CLI, make sure you have a hosting account with SSH access. Most shared hosting providers do not give you access to SSH. Providers like DigitalOcean, Linode and AWS are ideal for this if you love to spin up your own servers.
Other requirements are basic:
PHP 5.3.2 or later.
WordPress 3.4 or later.
UNIX like environment like Linux.
How to Install WP-CLI
First connect to your server’s command line through SSH. You can install the latest version of WP-CLI using the cURL or wget command. The WP-CLI installation file is available as a phar file and the latest version can be found at:
This will download and extract the WP-CLI files to your root user directory.
Next, we will set the permissions to make it executable. Enter the following command:
chmod +x wp-cli.phar
Optionally, we can move wp-cli.phar to a folder and rename it to wp. This will help us use the WP-CLI commands by just typing ‘wp’ at the start of the commands.
sudo mv wp-cli.phar /usr/local/bin/wp
That’s it! Now we can jump in to use many of the WP-CLI commands.
Basic WP-CLI Commands
To keep it simple, we’re going to overview the basic WP-CLI commands. You can explore more commands here.
Using the WP-CLI Help System
WP-CLI comes with a full help system that you can access by typing “wp help”, for example:
wp help cache
Will display information as:
Manage the object cache.
wp cache <command>
add – Add a value to the object cache. decr – Decrement a value in the object cache. delete – Remove a value from the object cache. flush – Flush the object cache. get – Get a value from the object cache. incr – Increment a value in the object cache. replace – Replace an existing value in the object cache. set – Set a value to the object cache. type – Attempts to determine which object cache is being used.
wp cache set my_key my_value my_group 300
wp cache get my_key my_group
You can use the help system to understand what you can do with the commands and their respective subcommands.
Installing WordPress with WP-CLI
If you haven’t installed WordPress by using any other method on your server, then you can easily do so using WP-CLI command wp core install. Along with that command we need to pass parameters such as URL, Title, Admin Username, Password and Admin Email.
Importing and installing themes is much quicker through WP-CLI than going into WordPress admin, searching and then activating it.
It connects your server directly to the WordPress theme repository and imports the theme in a matter of a few seconds. For example, to install a theme like TwentyTen, we will use the following command:
wp theme install twentyten
Similarly, to install P2 theme, our command will become:
wp theme install p2
To activate the themes on your WordPress website, you will need to use the following command:
wp theme activate p2
Installing Plugins with WP-CLI
Just like the themes, plugins can also be installed right from the official repository. Installation is seamless and takes almost no time.