If you’ve ever shopped around for WordPress hosting, you’ve probably seen this weird little acronym that shows up on many hosts’ features lists:
Are you familiar? Most managed WordPress hosts offer it nowadays.
Impressively, it manages to pack two different acronyms into a name that’s the perfect storm for confusing beginners. So what does this acronym mean? And why should you care about it?
If you’re a WordPress developer, you’re probably already familiar with WP-CLI, or at least the concept of command line interfaces. Which is why this post isn’t really for you.
Instead, this post is focused on giving regular WordPress users a basic understanding of WP-CLI. I’m not going to argue that every WordPress user should start using WP-CLI – this post is just a fun way for regular ‘ole WordPress users to learn more about the WordPress ecosystem.
What is WP-CLI?
Ok, I already told you that this is two acronyms jammed into one. The WP stands for, unsurprisingly, “WordPress”. And the CLI stands for “command line interface.
Put it all together and you get…WordPress command line interface.
Ok, great. It’s a command line interface for WordPress…what the heck is a command line interface?
Command line interfaces are what you normally see super smart “hackers” typing away at in popular TV shows. That is, they look like this:
And if you used a computer before the, oh…1970s, that’s the only way you could interact with it.
With command line interface, you basically “speak” to the computer in a series of text commands, rather than using your mouse to click buttons on your screen (or some other type of input).
For casual users, command line interfaces aren’t exactly user friendly (to say the least). But if you know your way around the commands, it can actually save you time. Which was why WP-CLI was born.
What Can You Do With WP-CLI?
Basically, WP-CLI lets you manage most aspects of your WordPress site without needing to log into your dashboard. If you’re only managing a single WordPress site, this might not be a huge draw. But if you need to work with multiple sites, you can start to see the appeal of that.
Or, it can also help out if you need to do other things for testing like programmatically generating a few hundred posts. And lots more!
Here’s some of what you can do with WP-CLI:
- Install a plugin or theme
- Delete a plugin or theme
- Update a plugin or theme
- Run a backup
- Delete a post (or lots of posts)
- Clear your transients cache
- Create an export file
- Back up your database
- Lots, lots more
You can even write a post directly from WP-CLI! Though, to be fair, it’s probably a bit easier to use the WordPress Editor for that.
How to Use WP-CLI to Manage WordPress
Unfortunately, you can’t just hop into cPanel and start playing around with WP-CLI. You’ll need something called SSH access, or Secure Shell access.
Depending on your host, you:
- May already have SSH access
- Might need to enable SSH access through cPanel
- Might need to ask your host to enable it for you
- Won’t be able to get SSH access (for some shared hosts)
If you want to really go ahead and use WP-CLI – it’s probably best to ask your host for help getting set up.
Once you’ve got that, you’re ready to start firing off some WP-CLI commands (assuming your host supports WP-CLI – otherwise you might need to install it first). I’ll show you these using PowerShell for dramatic effect, though I’m not actually connected to anything right now.
How to Install a WordPress Theme With WP-CLI
WP-CLI lets you install any theme at the WordPress.org directory with a command that’s shorter than this sentence is.
For example, if you wanted to install the Twenty Seventeen WordPress theme with WP-CLI, all you’d need to do is use the command:
wp theme install twentyseventeen
Want Twenty Sixteen instead? You guessed it:
wp theme install twentysixteen
How to Manage WordPress Plugins With WP-CLI
It’s pretty much the same deal for WordPress plugins. If you wanted to install the Akismet plugin (or any other plugin from WordPress.org), you’d just use this short command:
wp plugin install akismet
Then, to activate your plugin, you could just type:
wp plugin activate akismet
And if you changed your mind about comment spam because you missed all of those kind people complimenting your blog posts with spun comments, then you could go ahead and deactivate Akismet by using:
wp plugin deactivate akismet
Simple enough, right? No weird computer language – the commands are pretty much written in plain English.
Other Cool WP-CLI Commands
WP-CLI lets you do far more than just install and activate themes and plugins. Here are some other nifty commands you can use.
Do Regular WordPress Users Need to Use WP-CLI?
Don’t go running off to get SSH access quite yet…
In most cases, the answer is a resounding no. This post is just to educate you on a theoretical part of WordPress because I think it’s cool. If you’re just a regular WordPress user managing your own site, you really don’t need to worry about WP-CLI as it applies to your own site.
If the concept of WP-CLI interests you, say, as part of learning WordPress development, then I encourage you to set up a test environment and play around with it. That’s about the level I’m at – I’m far from an expert, here.
No matter what – make sure you’re running commands in a place where you can’t break anything. While there’s no “wp completelyobliteratesite” command (that I know of!), you still definitely don’t want to get caught playing around on your live sites.
Wrapping Things Up
If you master it, WP-CLI is a powerful tool to help you manage all of your WordPress sites. Nowadays, many WordPress focused hosts offer WP-CLI by default, which is making it more accessible (you can even find a full list of all those hosts here).
But if you’re a beginner, you’re still better off leaving WP-CLI to the professionals. But now, you’ll at least know what you’re paying for the next time you see WP-CLI on a WordPress host’s feature list!
Now over to you – if you do use WP-CLI, I’d love to hear more about how it helps streamline your WordPress experience.