Getting Started with WP-CLI


View this video on YouTube here:

This is the first video in a short series on working with WP-CLI, over the next few weeks we will be releasing additional videos for both WP-CLI as well as other topics. These video tutorials are possible due to my amazing Patrons through Patreon.

Getting going with WP-CLI

First off apologies for the sound quality and weird video issues at the end, the wonders of Youtube’s encoding are responsible for the later! As for the sound quality, in our first take the sound quality was truly awful, (those of you who follow me on twitter will know that we came up with a simple but effective solution). Our second take was much better and is the audio you’re hearing for most of the video. However, in post production I noticed a couple of mistakes and quickly went back to re-record. The only problem being that we’d made further improvements to the mic setup, so the sound quality is better but our dubbing is fairly obvious. Rather then re-record the whole thing again we decided that as this is the first video people will forgive us.

If you’re going to follow along then you’ll need to get wp-cli installed. Before you start head over to and download, remember you’re installing this on your server, not your local machine (unless it’s also your server, for example a dev environment) for this tutorial. In the next tutorial we’ll look at remotely connecting to sites using the WP-CLI tool, but for now we’ll assume that WP-CLI is installed on your server. If you’re installing on a windows machine you can either use Cygwin which comes bundled with solutions like XAMP or use the Powershell wrapper remember you only need to install WP-CLI where you’re running WordPress. For Mac and Linux users the install is just a case of following the 3 simple steps.

As WP-CLI uses the terminal, if you’re using it on your server, you’ll need some sort of shell access to your remote server to run WP-CLI on it. Many hosts offer SSH access to allow you to communicate with your server via your local terminal or on Windows applications such as Putty. Not all hosts provide this feature, especially on cheaper plans and shared hosts, so if you’re not sure check with your host if they offer this feature. You will also find some hosts have WP-CLI installed by default, if this is the case then you don’t need to install it again (if you’re not sure check with your host).

This tutorial was recorded using a VVV vagrant install which is a virtualised instance of a development server, which comes with WP-CLI installed by default.

In this first episode we’re going to cover some basic features and use cases for WP-CLI, it’s a quick introduction, remember you can always get help and look up individual parameters for a command on the site or using the built in help (I find that it’s quicker to do this via the site).
In this first video we’ll be covering:

  • Checking WP-CLI is installed and up to date
  • Looking at WordPress Core versions
  • Manipulate plugins, listing, installing, activating and uninstalling
  • Running backups, both SQL dumps and using WordPress Export tool
  • Installing and Updating WordPress Core
  • Manipulating WordPress through interactive shell
  • Writing simple SQL queries against the database
  • Writing a really simple database back up script

If you are not familiar with the command line generally, don’t worry. A couple of useful commands, you’ll see used on screen but not referenced in the video are:

  • cd – Change Directory its usage is cd folder/I/want/to/move/to
  • ls – list the contents of a directory
  • . – . followed by space and a file name, tells the shell to run that command for example .

For this tutorial that’s pretty much all the commands you need to know, though I would encourage you to have a play with other commands.

Coming up next

The next two videos in this series will start to get a little more in-depth. Some of the highlights include:

  • Working with wp-cli.yml files for more advanced config options
  • Remotely controlling WordPress sites through WP-CLI via SSH and using WP-API
  • More complex Shell Scripting and using WP-CLI to automate a lot of your everyday tasks
  • Running scripts directly through WP-CLI using its eval command
  • Extending WP-CLI to create your own commands through your own plugins

Patreon Patrons


It’s only because of these fine people that videos like this are produced, if you want to help me film more video tutorials then please do consider becoming a Patreon Patron. For more information on why I chose to fund these videos through Patreon please see my introduction to Patreon post. Or to jump straight in and become a Patron by donating $1 or $5 visit my Patreon page for details.

Helping you and your customers stay safe

WordPress Security Consulting Services

Power Hour Consulting

Want to get expert advice on your site's security? Whether you're dealing with a hacked site or looking to future-proof your security, Tim will provide personalised guidance and answer any questions you may have. A power hour call is an ideal starting place for a project or a way to break deadlocks in complex problems.

Learn more

Site Reviews

Want to feel confident about your site's security and performance? A website review from Tim has got you covered. Using a powerful combination of automated and manual testing to analyse your site for any potential vulnerabilities or performance issues. With a comprehensive report and, importantly, recommendations for each action required.

Learn more

Code Reviews

Is your plugin or theme code secure and performing at its best? Tim provides a comprehensive code review, that combine the power of manual and automated testing, as well as a line-by-line analysis of your code base. With actionable insights, to help you optimise your code's security and performance.

Learn more

Or let's chat about your security?

Book a FREE 20 minute call with me to see how you can improve your WordPress Security.

(No Strings Attached, honest!)