Blog · Guides

wp-cli Essentials: Manage WordPress 10x Faster from the Terminal

If you manage more than one WordPress site, or even just one site with a lot of moving parts, the terminal is faster than the dashboard almost every time. wp-cli is the standard command line tool for WordPress, and once a handful of commands are muscle memory, tasks that used to take five clicks and a page reload take five seconds. This guide walks through the 20 commands worth knowing, with real examples you can copy and adapt.

Getting started

Most managed hosts, including LiteSpeed based stacks running PHP 8.1 through 8.3, ship wp-cli pre-installed and accessible over SSH. Confirm it works and see what version of WordPress you are running with:

wp core version
wp --info

Run commands from your WordPress root directory (where wp-config.php lives). If you are working as a non-root user with proper file ownership, you will not need the --allow-root flag. If you manage a multisite network, add --url=example.com/subsite to target a specific site in the network.

Plugins and themes: bulk actions in seconds

This is where wp-cli earns its keep immediately. Instead of logging in, navigating to Plugins, and clicking Update one at a time:

wp plugin list
wp plugin update --all
wp plugin install woocommerce --activate
wp plugin deactivate hello-dolly
wp plugin delete hello-dolly

wp plugin list shows every installed plugin with its status and available updates, which is the fastest way to audit a site you have just inherited. wp plugin update --all updates everything in one pass. Theme management follows the same pattern:

wp theme list
wp theme activate twentytwentyfour
wp theme update --all

For a site running dozens of plugins, this alone can turn a 20 minute maintenance window into a 90 second one.

Users and content management

User administration from the CLI is especially useful when you are locked out of wp-admin or troubleshooting a login issue:

wp user list
wp user create newadmin [email protected] --role=administrator --send-email
wp user update 1 --user_pass=newStrongPassword123
wp user delete 5 --reassign=1

You can also reset a lost admin password without ever touching the login screen, which matters when a plugin conflict has broken the dashboard entirely. Content operations are equally direct:

wp post list --post_type=page --format=table
wp post delete 42 --force

Database: search-replace and backups

This is the command that saves the most time overall. Migrating a site from staging to production, or from an old domain to a new one, means every serialized URL reference in the database needs updating consistently. Doing this with a plain SQL find-and-replace breaks serialized PHP arrays. wp-cli handles it correctly:

wp search-replace 'https://staging.example.com' 'https://example.com' --all-tables
wp search-replace 'oldtext' 'newtext' --dry-run

Always run with --dry-run first on a production database so you can see exactly how many rows will change before committing. Backups and restores are just as direct:

wp db export backup-$(date +%F).sql
wp db import backup-2024-01-01.sql

Piping wp db export into a scheduled cron job is a simple, dependable backup layer to sit alongside whatever snapshot system your host provides.

Cache, transients, and cron

If your stack uses Redis or Memcached for persistent object caching (recommended alongside PHP 8.3 with OPcache for a fast baseline), you will occasionally need to clear it without waiting for the dashboard:

wp cache flush
wp transient delete --all

Note that wp cache flush clears the object cache, but full-page cache from LiteSpeed Cache or Cloudflare’s edge cache needs to be purged separately. LiteSpeed Cache exposes its own wp-cli commands for this, so you can trigger a full-page cache purge from the same script that runs your deploy, rather than logging into a separate panel. If your object cache plugin ships CLI integration (many Redis-based plugins do), you can check status and toggle it the same way:

wp redis status
wp redis enable

Cron is another area where the CLI beats the dashboard for visibility. WordPress’s cron system only fires on page loads by default, which means scheduled tasks can silently stall on low-traffic sites. You can inspect and force-run pending events directly:

wp cron event list
wp cron event run --due-now

Pairing this with a real system cron job that calls wp cron event run --due-now on a schedule is more reliable than depending on visitor traffic to trigger WordPress’s pseudo-cron.

Core updates and maintenance mode

Keeping core current matters for both security and Core Web Vitals performance work, since core updates often ship rendering and query improvements. Update and verify in two commands:

wp core update
wp core update-db

For anything riskier, like a major plugin update or a database migration, put the site into maintenance mode first so visitors see a holding page instead of a half-updated site:

wp maintenance-mode activate
wp maintenance-mode deactivate

Rounding out the list, wp option get and wp option update let you read or change any entry in the options table directly, which is handy for fixing a broken siteurl value or checking what a plugin actually wrote to the database:

wp option get siteurl
wp option update blogname 'New Site Name'

Putting it together

The real power of wp-cli shows up when you chain commands into a script. A simple deployment routine might look like this:

wp maintenance-mode activate
wp plugin update --all
wp core update-db
wp cache flush
wp maintenance-mode deactivate

Run that as a single shell script over SSH, or wire it into a CI/CD pipeline, and routine maintenance stops being a manual chore. It also becomes auditable: you have a script you can read back and version control, instead of a memory of which buttons you clicked in which order.

The takeaway

You do not need to memorize every wp-cli subcommand, there are hundreds. But the twenty or so covered here, plugin and theme management, user administration, search-replace, cache and cron control, and core updates, cover the vast majority of day to day WordPress administration. Once they are second nature, the terminal becomes the fastest path to a well-run site, and the dashboard becomes the place you visit only when you actually want to.