
WordPress admins and developers know a unique kind of frustration. You might know exactly what you need to do, from updating a plugin, flushing cache, fixing a bad URL, exporting content, or checking cron, but you still have to click through several screens, wait for the admin UI to load, and hope nothing times out in the process.
WP-CLI flips that experience on its head.
With WP-CLI, you manage your site from the command line instead of relying on /wp-admin/. There are no tabs to juggle, no searching for the right settings, and no guessing where a button is hidden. You run a command, see the result, and move on.
If you haven’t tried WP-CLI before, it might seem like a tool just for developers. In reality, it’s one of the easiest power tools in WordPress, especially when you see that it handles the same routine tasks you do in the dashboard, only faster and with less hassle.
Below, we’ll cover the types of WordPress tasks that become much easier with WP-CLI, like updates, maintenance mode, caching, database work, search-and-replace, user and content management, cron debugging, and automation. We’ll also share some commands and habits along the way that make WP-CLI feel powerful and safe.
A quick note for Pagely customers
If you are hosting on a standard VPS, you might be used to typing wp, as shown in the examples below, to trigger the interface. However, if you’re hosting on Pagely, because a server might be running multiple applications with different PHP versions, we utilize a specific pagely-wp wrapper for our customers.
This command ensures that when you execute a function, you are using the exact PHP version assigned to that specific WordPress application. This reduces confusion and makes it easier to standardize WP-CLI in your maintenance and deployment routines.
Getting your bearings
WP-CLI runs wherever your WordPress install runs. Typically, that means:
- You SSH into the server (or container) running your site.
- You cd into the WordPress root directory (where wp-config.php lives).
- You run
wp …commands against that install.
A quick way to confirm you’re in the right place is to run:
wp --info
You’ll see the WP-CLI version, the PHP binary being used, and other details that matter when you’re troubleshooting “works on staging, fails in production” situations.
If you’re ever unsure what WP-CLI can do, the help output is genuinely useful:
wp help
And for any specific command:
wp help plugin
wp help search-replace
wp help db export
The built-in help is a great feature of WP-CLI. It gives you access to documentation right in your terminal, so you don’t have to switch away from your work.
You can also browse the official command reference online when you want the bigger picture (or you’re sharing a link with a teammate): WP-CLI and the commands directory.
Your “first five minutes” workflow
When you jump onto a WordPress site, especially one you don’t touch daily, you usually want the same quick pulse check:
- What version of WordPress is running?
- What’s the site URL set to?
- Are plugins/themes up to date?
- Is anything obviously broken?
WP-CLI is perfect for this.
wp core version
wp option get siteurl
wp option get home
wp plugin status
wp theme status
These commands provide the basics without needing to log in. If you manage several sites, you’ll notice how consistent this approach is across different environments.
Here’s a tip to save you trouble later: WP-CLI supports global flags like --path and --url, letting you target a specific install or multisite setup without changing directories or guessing your environment. Once you start scripting with WP-CLI, these flags are very helpful.
Updates without the anxiety spiral
Updates are a key part of WordPress maintenance. You need to work quickly but also stay in control, and WP-CLI helps you do both.
Updating WordPress core
wp core check-update
wp core update
If the database needs an update afterward:
wp core update-db
Updating plugins and themes
To see what’s outdated:
wp plugin list --update=available
wp theme list --update=available
Update dry run:
wp plugin update --all --dry-run
wp theme update --all --dry-run
To update everything:
wp plugin update --all
wp theme update --all
This is where WP-CLI stands out: you can organize updates into a clear, repeatable process, especially when working on staging sites.
A simple “safe update rhythm” looks like:
- Put the site in maintenance mode (if you’re making impactful changes).
- Export a database backup.
- Update core/plugins/themes.
- Flush cache.
- Run a quick smoke test.
This process might seem like more work than just clicking “Update,” but it’s actually easier to remember because the steps stay the same. When you can rely on these steps, you’re more likely to update regularly, which is important for security and stability.
Maintenance mode that you can toggle in seconds
If you’re about to make major changes, like big plugin upgrades, migrations, switching themes, or large search/replace jobs, turning on maintenance mode is a simple way to be considerate to visitors and helps avoid unexpected issues while you work.
WP-CLI can toggle it cleanly:
wp maintenance-mode activate
…do your work…
wp maintenance-mode deactivate
You might not use maintenance mode every day, but you’ll appreciate it the first time you need it quickly, especially if the admin dashboard is slow and you want to protect the site while fixing an issue.
Cache management when “refresh” isn’t enough
Caching is a major reason modern WordPress sites run well, but it can also cause changes to not show up when you expect them.
WP-CLI can help you eliminate guesswork.
Flush WordPress object cache
If your site uses an object cache (Redis/Memcached, etc.), this is the command you’ll reach for constantly:
wp cache flush
This command clears the object cache as WordPress sees it. It may not clear every layer of caching, like CDN, reverse proxy, or page cache, but it’s often the missing step after making configuration changes, updating plugins, or migrating your site.
After any automated deployment or scripted update, add a cache flush unless you know your setup handles it automatically. This small step can prevent a lot of confusion.
Database operations without the stress
The database is at the core of WordPress. While themes and plugins may change, the database is something you need to handle carefully.
WP-CLI gives you tools that are both powerful and (when used thoughtfully) safer than ad-hoc manual SQL.
Back up before you touch anything
If you only memorize one WP-CLI database command, make it this:
wp db export ~/backup-$(date +%F-%H%M).sql
Getting into the habit of exporting first, then making changes, turns stressful maintenance into a more controlled process. If something goes wrong, you won’t be scrambling.
Check database size and table hotspots
Want to understand what’s growing and why backups take forever?
wp db size
wp db size --tables
Large tables can signal real issues, such as runaway transients, bloated logs, a plugin storing too much data, or an ecommerce store that has grown significantly.
Search the database (fast)
Sometimes you’re hunting for a stray domain, an old staging URL, or a suspicious snippet.
wp db search 'old-domain.example'
To extend the search to all tables with your WordPress table prefix:
wp db search 'old-domain.example' --all-tables-with-prefix
And if you truly need to search everything, including non-standard tables, you can use the --all-tables flag. This can have unintended consequences, especially if multiple applications share the same database, so use with caution:
wp db search 'old-domain.example' --all-tables
Run a targeted query
WP-CLI can execute SQL directly:
wp db query "SELECT ID, post_title FROM wp_posts WHERE post_status='draft' LIMIT 10;"
This is helpful when you need a quick, precise answer without opening another database client.
If you’re doing more than a quick inspection, treat it like real database work (test on a staging site first and proceed carefully).
Search and replace: the command that saves migrations
If you’ve ever migrated a WordPress site and ended up with broken images, mixed-content warnings, or links still pointing at staging, you already know why search/replace matters.
WP-CLI’s search-replace command is well known because it handles serialized data safely, something many manual methods do not manage well.
The best practice is always to dry run first:
wp search-replace 'old.example.com' 'new.example.com' --dry-run
Review the output. If it looks right, run it for real:
wp search-replace 'old.example.com' 'new.example.com'
Migration best practices: don’t casually rewrite GUIDs
By default, WP-CLI does not modify the guid column in the wp_posts table, and that’s intentional. GUIDs are meant to be permanent identifiers and are often used by feeds, external systems, and integrations. Changing them can cause subtle and hard-to-debug issues.
If you want to be explicit (and safer in scripts), you can tell WP-CLI to skip GUIDs entirely:
wp search-replace 'old.example.com' 'new.example.com' --skip-columns=guid
Only rewrite GUIDs if you fully understand the downstream impact and have a specific reason to do so.
If you’re dealing with custom tables or unusual setups, you may also need:
wp search-replace 'old.example.com' 'new.example.com' --all-tables-with-prefix
Use --all-tables only as a last resort, especially on servers where multiple applications share the same database.
After any search/replace operation, flush caches (at least the object cache) so you’re not viewing stale data.
If you want a deeper look at options and edge cases, the official docs are worth bookmarking.
Exporting and importing content without babysitting a browser tab
Sometimes you don’t need a full site migration. You need content portability: move posts/pages, migrate authors, or stage a content refresh.
WP-CLI can export content in WordPress eXtended RSS (WXR) format:
wp export
If you want to limit scope, you can filter by post type or status. And if your environment includes the import command (often installed as a WP-CLI package), importing looks like:
wp import /path/to/export.xml --authors=create
That --authors=create flag is especially helpful when you’re moving content between environments and don’t want to manually recreate user accounts first.
For teams doing migrations or content merges often, this becomes a repeatable pattern, and repeatable is the whole point. The more “one-off” your process is, the more likely something subtle gets missed.
Managing users and permissions without clicking through profiles
User management is another area where WP-CLI is very effective.
Need to quickly list users?
wp user list
Need to reset a password without emailing links or logging in as an admin?
wp user update admin --user_pass='a-strong-new-password'
Be careful where you use that command, as shell history can store sensitive information.
Roles and capabilities
Roles are what you see, but capabilities are the actual permissions. Most sites never need custom capabilities, but some do, especially membership sites, editorial workflows, or tightly controlled enterprise setups.
WP-CLI lets you inspect and modify capabilities without writing custom code:
wp cap list editor
wp cap add editor manage_options
wp cap remove editor manage_options
If you want the canonical reference for what roles and capabilities mean in WordPress, the official Roles and Capabilities documentation has what you need.
Comments and moderation from the terminal
If you’ve ever dealt with a comment flood (spam happens) or needed to clean up a specific post’s comment thread, WP-CLI can be a quiet lifesaver.
List comments:
wp comment list
Filter to a post:
wp comment list --post_id=123
Approve, unapprove, mark as spam, trash, or delete:
wp comment approve 456
wp comment spam 456
wp comment trash 456
wp comment delete 456 --force
It’s not glamorous, but it’s efficient. And efficiency matters when the “job” is repetitive and time-sensitive.
WP-Cron: testing scheduled tasks without guesswork
WP-Cron usually works well, but sometimes issues arise. For example, low traffic can prevent cron from running, scheduled posts might fail, or background tasks can build up.
WP-CLI gives you visibility:
wp cron event list
You can run anything due now:
wp cron event run --due-now
And if you want to validate cron spawning behavior:
wp cron test
Language packs and internationalization tools
Running WordPress in multiple languages or managing translations for plugins and themes is much easier with WP-CLI.
You can list and install language packs for core:
List / Install
wp language core list
wp language core install es_ES
Activate
wp site switch-language es_ES
If you want “install + activate” in one step:
wp language core install es_ES --activate
And similarly for plugins/themes:
wp language plugin list my-plugin
wp language theme list my-theme
If you build plugins/themes, WP-CLI can even generate translation template files:
wp i18n make-pot wp-content/plugins/my-plugin
This feature helps teams make localization a regular part of their workflow, rather than something they handle at the last minute.
A few habits that make WP-CLI feel “safe”
WP-CLI is a powerful tool. The goal is not to be afraid of it, but to use it consistently.
A few habits go a long way:
- Prefer staging first for anything that changes the database or updates core dependencies.
- Export before you modify (especially before search/replace).
- Use
--dry-runwhen available, and read the output instead of rushing. - Flush caches intentionally after impactful changes.
- Use
--skip-plugins/--skip-themesif you suspect a plugin/theme is causing errors during CLI execution (this can help you recover when the site is otherwise misbehaving).
If WP-CLI commands are failing because WordPress can’t fully load, skipping plugins or themes can mean the difference between a site that is down and one you can fix.
Putting it all together: adopting a command-line caretaker mindset
Once you get comfortable with WP-CLI, something shifts.
WordPress becomes less about managing a dashboard and more about operating a system. You can check status, make changes, and confirm results more easily. Your maintenance routine becomes consistent, you can automate tasks, and you can keep working smoothly even under pressure.
Most importantly, you’ll spend less time thinking, “I know what to do, but I don’t want to click through all of this again.”
If you’re curious about building a more automated, WP-CLI-driven operational routine, our Managed Hosting for WordPress is designed for exactly that. And if you’re already a customer, your support team can help you align WP-CLI usage with your specific stack and traffic patterns.
WP-CLI is a valuable tool, but the real benefit is the peace of mind you get from using it regularly.

