Tutorials UPDATED: 26 August 2021

What is WP-CLI? A Beginner’s Guide

Simon Dwight Keller

5 min read
Image for What is WP-CLI? A Beginner’s Guide

WordPress is one of the easiest ways to create a website, the platform itself being free. Although you still have to get a hosting service, users with no experience can build a clean and responsive website from scratch in no time.

But that’s not to say there’s nothing for developers who, unlike the rest of us average joes, are good with code and like to experiment.

Enter the WP-CLI.

So, what is it? And how does it unlock new doors to maximizing your WordPress experience?

Let’s have a look.

What Exactly is WP-CLI?

It’s short for WordPress Command Line Interface.

Since 2003, WordPress has been an open-source software, which means developers have been able to alter its code.

The command line feature has expanded on this, allowing users to perform tasks without the WordPress Graphic User Interface (GUI) dashboard.

WP-CLI is an alternative to using the GUI and gives you the ability to modify and manage your WordPress site via a command line.

What Can I Use the WP-CLI for?

You can perform any task with WP-CLI instead of using the WordPress Dashboard.

Here are some tasks you can complete with WP-CLI:

  • Creating a new website
  • Installing a new WordPress package
  • Installing and monitoring the status of plugins and themes
  • Handling bulk file uploads
  • Creating backups
  • Tweaking permissions and other security settings


Installing and activating a new plugin is written with the command code below:

wp plugin install user-switching --activate

And the output should look like this:

Installing User Switching (1.0.9)
Downloading installation package from https://downloads.wordpress.org/plugin/user-switching.1.0.9.zip...
Unpacking the package...
Installing the plugin...
Plugin installed successfully.
Activating 'user-switching'...
Plugin 'user-switching' activated.
Success: Installed 1 of 1 plugins.

Here is a list of some basic commands:

  • admin       Open admin in a browser.
  • approve   Approve a comment.
  • cache        Manage the object cache.
  • cli               Manage WP-CLI itself.
  • comment Manage comments.
  • core           Download, install, update and manage a WordPress install.
  • create       Create a new comment.
  • delete       Delete a comment.
  • export       Exports WordPress content to a WXR file.
  • find            Find WordPress content to WXR file.
  • help           Gets help on WP-CLI, or on a specific command.
  • language Installs, activates, and manages language packs.
  • plugin       Manages plugins, including installs, activation, and updates
  • theme       Manages themes, including installs, activations, and updates.

A more detailed list of the WP-CLI commands is available if you need more information on the basic functions you can perform.

How To Get Started With WP-CLI?

So, we’ve talked about how awesome this tool is and how you can perform simple tasks from your command line on your WordPress website.

But how do you get started?

Install WP-CLI

Although it can seem challenging at first glance, we’ve outlined the basics steps below to make it easier to follow.

First, download the latest WP-CLI software in a PHP archive format (short for Phar)

You can do this using the Wget program or the cURL software outlined below:

curl - 0 https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

Now, let’s open the file and make sure the WP-CLI archive is functioning properly with:

php wp-cli.phar --info

To use WP-CLI in the command line by typing “wp” rather than “php wp-cli.phar” you’ll need to make the file executable. To do this, move it somewhere in your PATH. For example:

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

After you have seen a successful installation, you should see an output similar to this when you run (wp –info):

$ wp --info
OS:  Darwin 16.7.0 Darwin Kernel Version 16.7.0: Thu Jan 11 22:59:40 PST 2018; root:xnu-3789.73.8~1/RELEASE_X86_64 x86_64
Shell:  /bin/zsh
PHP binary:       /usr/local/bin/php
PHP version:       7.0.22
php.ini used:   /etc/local/etc/php/7.0/php.ini
WP-CLI root dir:        /home/wp-cli/.wp-cli/vendor/wp-cli/wp-cli
WP-CLI vendor dir:      /home/wp-cli/.wp-cli/vendor
WP-CLI packages dir:    /home/wp-cli/.wp-cli/packages/
WP-CLI global config:   /home/wp-cli/.wp-cli/config.yml
WP-CLI creen shotproject config:
WP-CLI version: 2.4.0

Now you’re good to go!

In Conclusion

There are endless commands and functions you can perform with WP-CLI. But first, familiarize yourself with the software and its capabilities.

We recommend the following resources for you:

Getting started will require time and practice. Build a knowledge base and experiment with the commands.

As a WordPress website owner, adding WP-CLI to your collection can prove to be an efficient alternative to performing tasks using the GUI dashboard.

This is a guest post contributed by Simon Dwight Keller from SDK Marketing, a Content Marketing Agency specializing in all things WordPress related!

Host your WordPress Website with Pressidium!

View our price plans

Host your website with Pressidium



Do you like this article?

Subscribe to our blog and get awesome WordPress content straight to your inbox.



Launch a WooCommerce Store in 60 Minutes or Less

Always wanted to run an online shop? Using WordPress and WooCommerce you could be up and running in 60 mins or less!
Alexander Newnham
Alexander Newnham
9 min read

The Benefits of Using a Staging Server with WordPress

Do you use a Staging Server to manage your WordPress website? Find out the top benefits of using a staging server as part of your workflow.
Alexander Newnham
Alexander Newnham
9 min read

Website Redesign Tips to Succeed!

Thinking about redesigning your website? We look at the top areas to focus on with a website redesign to make sure you reach your goals!
Ioanna Aravani
Ioanna Aravani
10 min read

Part 2 – WordPress and Object Oriented Programming: A Real World Example

In the second part of our series on Object-Oriented Programming we look at a real world scenario where OOP offers a superior way to program.
Tassos Antoniou
Tassos Antoniou
15 min read