Welcome to the NZRT Wiki Podcast. Today we’re looking at 💻 WP CLI Cheatsheet.
So let’s start with the basics. WP-CLI is the command-line interface for WordPress. What that means for you is that instead of logging into the WordPress dashboard in your browser and clicking through menus, you can type commands directly into a terminal and get things done faster. It’s especially useful when you’re managing sites remotely, running bulk operations, or automating repetitive tasks.
Let’s walk through the main command groups you’ll use day to day.
First up, posts. There are four key things you can do here. You can list all posts currently in the system, you can pull up a specific post by its numeric ID, you can create a brand new post by providing a title, and you can delete a post by its ID. Simple, direct, and no browser required.
Next, plugins. This is where WP-CLI really shines. You can list all installed plugins so you can see what’s active and what’s not. You can activate a specific plugin by name, deactivate it, or install a new one straight from the WordPress plugin repository. And if you want to keep everything up to date in one go, there’s a command to update all plugins at once. That last one is a real time-saver on sites with a lot of plugins.
Then there’s user management. You can list all users on the site, create a new user by supplying a username, an email address, and a role like editor or administrator, delete a user by their ID, and even add specific capabilities to a user account. That last one is handy when you need to grant someone a particular permission without changing their entire role.
Moving on to the database. WP-CLI gives you three essential database commands. You can export the entire database to a SQL file, which is great for backups before you make any big changes. You can import a SQL file back in, which is useful for restores or migrations. And you can run an optimize command, which cleans up the database tables and can help with performance on older or high-traffic sites.
Finally, options. WordPress stores a lot of site configuration in what it calls options. You can retrieve the value of any option by name, update it with a new value, or list everything in one go. A common use case here is updating the site URL when you’re migrating a site from one domain to another.
Now, an important practical note. WP-CLI availability on your Hoopla shared cPanel hosting is not guaranteed. It depends on what the host has installed. The best way to check is to open an SSH terminal session through cPanel and see if the command is recognised. If it’s not available, don’t worry. You can fall back to the WordPress admin interface or cPanel’s built-in tools to accomplish the same things.
If you do have SSH access and WP-CLI is not installed, you can install it yourself. The process involves four steps. You download the WP-CLI package file using curl, you make that file executable, you move it to a system location so it’s available as a global command, and then you verify the installation by checking the version number. Once that’s done, you’re good to go.
One thing to keep in mind when using WP-CLI: you generally need to run commands from inside the WordPress installation directory, or point the tool at the correct path. If you’re getting errors about WordPress not being found, that’s usually the first thing to check.
For anyone at NZRT working on WordPress projects, WP-CLI pairs well with the broader WordPress workflow. The wiki has related notes covering WordPress as a platform, plugin development, and theme development, so if you want to go deeper on any of those areas, those pages are worth a look.
To recap what we covered today: WP-CLI lets you manage WordPress entirely from the command line. You can handle posts, plugins, users, the database, and site options all without touching the browser. On shared hosting like Hoopla, check SSH first to confirm availability. And if you need to install it yourself, it’s a four-step process that takes only a few minutes.
That’s it for this episode of the NZRT Wiki Podcast. Thanks for listening.