WP-CLI commands every WordPress developer should know
The WP-CLI commands every WordPress developer should know, with examples you can copy: plugins, database, users, cache, cron, and search and replace.
The WP Waterfall team · Workflow

WP-CLI is the command line for WordPress. It runs the same code as wp-admin, so you can list plugins, change settings, export the database, and fix a broken site from a terminal without logging in. The commands below cover the work developers do every week. Each one was run against a real WordPress install before it went into this guide.
Key takeaways
- Run
wpfrom the folder that holdswp-config.php, or pass--path=/path/to/site. - Read first, then change:
list,get, and--dry-runcost nothing and show what a command would do. - Take a database export before any command that rewrites data.
How do you get started?
Check that WP-CLI works and what it sees:
wp --info
wp core version
wp core check-update
wp --info prints the PHP and WP-CLI versions. wp core version prints the WordPress version, and wp core check-update says whether a newer one exists. Add --allow-root only inside a container where you run as root, never on a server you share.
How do you manage plugins and themes?
wp plugin list --fields=name,status,update,version
wp plugin update --all --dry-run
wp plugin install query-monitor --activate
wp plugin deactivate query-monitor
wp plugin delete query-monitor
wp theme list --fields=name,status,update
The first line shows every plugin with its status and whether an update waits. --dry-run on an update lists what would change without changing it. When a site breaks after an update, wp plugin deactivate <slug> is the fastest way back in, and it works even when wp-admin shows a white screen. For the full routine, read How to fix a plugin update that breaks WordPress.
How do you work with the database?
wp db export backup.sql
wp db size --tables --human-readable
wp db check
wp search-replace 'https://old.example.com' 'https://example.com' --dry-run --skip-columns=guid
wp db export writes a full dump, and you should run it before anything that rewrites data. wp db size --tables lists table sizes, which finds a bloated wp_options or wp_postmeta quickly. wp db check looks for damaged tables.
wp search-replace changes text in every table and handles serialized data correctly, which a plain SQL replace does not. The --dry-run flag prints the number of replacements per table and changes nothing. Run it first. When the counts look right, run the same command without --dry-run. --skip-columns=guid leaves post GUIDs alone, which WordPress expects to stay the same. For a bigger cleanup, see Clean up a bloated WordPress database with WP-CLI.
How do you manage users?
wp user list --fields=ID,user_login,roles
wp user list --role=administrator --fields=ID,user_login,user_email,user_registered
wp user create editor1 editor1@example.com --role=editor --porcelain
wp user update editor1 --user_pass='a-long-new-password'
--porcelain prints only the new user ID, which is easy to use in a script. Listing the administrators is also the first check after a suspected break in. Never put a real password in a command you keep in shell history, and prefer a password manager's output.
How do you handle caches, rewrites, and transients?
wp cache flush
wp rewrite flush
wp transient delete --expired
wp cache flush clears the object cache, wp rewrite flush rebuilds the permalink rules, and wp transient delete --expired removes expired temporary data from the database. Use the rewrite flush when pretty permalinks return 404 after a deploy. To see whether a persistent object cache is installed, run wp cache type. The longer story is in WordPress object cache: what it is and when you need it.
How do you work with scheduled tasks?
wp cron event list --fields=hook,next_run_relative
wp cron event run --due-now
WordPress runs publishing, backups, and many plugin jobs through WP-Cron. The first command lists the events and when they run next. The second runs every event that is due, which clears a backlog when nobody visited the site. If you prefer a real server cron over visitor triggered cron, you can run that second command from the system crontab every few minutes.
How do you read and change content and settings?
wp option get blogname
wp option update blogdescription 'A short description'
wp post list --post_status=draft --fields=ID,post_title,post_status
wp config get DB_NAME
option get and option update read and write rows in wp_options. post list filters posts by status, type, or date. config get reads a constant from wp-config.php without opening the file.
How do you use WP-CLI in scripts?
Most list commands take --format and --field, which turn the output into something a script can read:
wp plugin list --status=active --field=name
wp plugin list --fields=name,version --format=json
wp --path=/var/www/example option get home
--field=name prints one value per line, and --format=json prints an array you can pass to jq. --path points WP-CLI at a site from any folder. On a WordPress network, add --url=https://example.com/blog to choose which site a command runs against.
Which commands are risky?
Treat these with care: wp db reset, wp db drop, wp search-replace without --dry-run, wp plugin delete, wp user delete, and wp eval, which runs any PHP you give it. Test them on a copy first, and take an export.
Can you run WP-CLI on WP Waterfall?
Yes. Open the WP-CLI page under Tools in the dashboard, or call it through the API. Both run an allowlist: eval, shell, db import, db drop, config set, and similar commands are refused. On a live site that uses Git, commands that change code, such as plugin install and plugin update, are also refused, because nothing may write code on live. Do those on staging and deploy.
An AI assistant connected through the WordPress MCP server uses the same allowlist with the run_wp_cli tool. A command that only reads runs at once, and a command that changes the site waits for your yes in the chat. The rules are in Run WP-CLI commands, and Let an AI agent run WP-CLI safely explains the safety model.
Read next
Related articles
Workflow · November 9, 2026How to run WordPress locally with DDEVHow to run WordPress locally with DDEV, step by step: install, start a site, set the PHP version, import a database and uploads, and take snapshots.
Workflow · September 23, 2026Run WordPress locally with DDEV against a real siteHow to run WordPress locally with DDEV against a real site: pull code, database, and uploads from WP Waterfall, edit, and push code back to staging.
Workflow · September 18, 2026Immutable live codeWhen a site uses Git, nothing writes PHP on the live environment. Code changes on staging, a deploy copies a release to live, and a rollback undoes it.