Skip to main content
WordPress DevelopmentJune 3, 2026

WP-CLI Commands Every WordPress Developer Needs in 2026

Master essential WP-CLI commands for WordPress developers in 2026, including updates, backups, search-replace, cron, users, cache, and debugging.

WP-CLI is one of the fastest ways to manage WordPress like a developer instead of clicking through the dashboard for every task. With the right commands, you can install WordPress, update plugins, export databases, run search-replace operations, manage users, flush cache, repair rewrite rules, debug cron jobs, regenerate media, and automate repetitive maintenance work from the terminal.

In 2026, WP-CLI is especially useful for developers managing staging sites, VPS-hosted WordPress projects, WooCommerce stores, agency client sites, multisite networks, CI/CD workflows, and emergency recovery tasks.

This guide is not a full command reference. It is a practical list of WP-CLI commands every WordPress developer should know, with examples, use cases, and safety notes.

TL;DR: Most Useful WP-CLI Commands

The most useful WP-CLI commands for developers are wp --info, wp core update, wp plugin list, wp plugin update --all, wp theme update --all, wp db export, wp db import, wp search-replace, wp cache flush, wp rewrite flush, wp cron event list, wp user list, wp option get, wp transient delete --all, wp media regenerate, and wp maintenance-mode activate. Before running destructive commands, always back up the database and use --dry-run where available.

What Is WP-CLI?

WP-CLI is the command-line interface for WordPress. Instead of logging into wp-admin and clicking through menus, you can run commands through SSH or terminal.

For developers, WP-CLI is useful because it is faster, scriptable, repeatable, and easier to use in deployment workflows. You can also run commands when the dashboard is slow, broken, or inaccessible.

Developers use WP-CLI for:

  • Installing WordPress quickly.
  • Updating core, plugins, and themes.
  • Creating backups and importing databases.
  • Running safe URL search-replace during migrations.
  • Managing users and roles.
  • Flushing rewrite rules and cache.
  • Debugging WP-Cron events.
  • Regenerating thumbnails.
  • Managing multisite networks.
  • Automating maintenance tasks.

Official reference: WP-CLI Quick Start.

Before You Run WP-CLI Commands

WP-CLI is powerful. That also means it can break things quickly if you run the wrong command on the wrong website.

Basic safety checklist:

  • Confirm you are inside the correct WordPress installation directory.
  • Run wp --info to confirm WP-CLI works.
  • Run wp option get siteurl to confirm the site you are controlling.
  • Back up the database before updates, imports, deletes, or search-replace operations.
  • Use --dry-run when supported.
  • Use staging before running risky commands on production.
  • Be extra careful on WooCommerce, membership, LMS, and booking sites.

Confirm WP-CLI is available:

wp --info

Confirm the current site:

wp option get siteurl
wp option get home

If these return the wrong site, stop before running any update, database, or search-replace command.

1. Check WP-CLI and WordPress Information

Start with environment checks. These commands tell you which WP-CLI version, PHP version, WordPress path, and site settings you are working with.

wp --info
wp cli version
wp core version
wp option get siteurl
wp option get home

When to use these:

  • Before running commands on a client site.
  • After SSH login to confirm the correct environment.
  • Before migrations or search-replace operations.
  • When debugging staging vs production confusion.

Developer tip: make it a habit to run wp option get siteurl before any database command. It can save you from accidentally changing the wrong site.

2. Install WordPress With WP-CLI

WP-CLI can install a fresh WordPress site quickly. This is useful for local development, staging sites, test installs, and scripted deployments.

wp core download

wp config create \
  --dbname=example_db \
  --dbuser=example_user \
  --dbpass='strong_password' \
  --dbhost=localhost

wp db create

wp core install \
  --url="https://example.com" \
  --title="Example Site" \
  --admin_user="adminuser" \
  --admin_password="strong_admin_password" \
  --admin_email="admin@example.com"

When to use this:

  • Creating a new staging site.
  • Building local development environments.
  • Automating new WordPress installs.
  • Testing plugin/theme compatibility on clean WordPress.

Official reference: wp core command.

3. Update WordPress Core Safely

WP-CLI makes core updates fast, but production updates should still be planned. Back up first, test on staging, then update production.

wp core check-update
wp core update
wp core update-db
wp core version

Useful examples:

# Check available updates
wp core check-update

# Update WordPress core
wp core update

# Run database updates after core update
wp core update-db

# Verify installed version
wp core version

Safety note:

For major WordPress updates, do not rely only on WP-CLI speed. Test important workflows first: login, editor, forms, checkout, custom post types, SEO output, cache, and admin screens.

4. Manage Plugins From the Terminal

Plugin management is one of the most common WP-CLI use cases. You can list plugins, check update status, activate/deactivate plugins, install new plugins, and update everything from SSH.

wp plugin list
wp plugin list --status=active
wp plugin list --update=available
wp plugin install query-monitor --activate
wp plugin deactivate plugin-slug
wp plugin activate plugin-slug
wp plugin update plugin-slug
wp plugin update --all

Useful examples:

# Show all plugins
wp plugin list

# Show active plugins only
wp plugin list --status=active

# Show plugins with updates
wp plugin list --update=available

# Install and activate a plugin
wp plugin install query-monitor --activate

# Deactivate a problematic plugin
wp plugin deactivate plugin-slug

# Update all plugins
wp plugin update --all

When to use this:

  • When wp-admin is slow or inaccessible.
  • When a plugin causes a fatal error.
  • Before and after a maintenance window.
  • When managing many sites through scripts.

Official reference: wp plugin command.

5. Manage Themes With WP-CLI

Theme commands are useful for updates, testing, emergency recovery, and switching to a default theme when a custom theme breaks the site.

wp theme list
wp theme status
wp theme update --all
wp theme activate twentytwentysix
wp theme install twentytwentysix

Useful examples:

# List installed themes
wp theme list

# Update all themes
wp theme update --all

# Activate a default theme
wp theme activate twentytwentysix

When to use this:

  • Theme conflict troubleshooting.
  • Testing default theme behavior.
  • Recovering after broken custom theme code.
  • Updating inactive themes for security.

Official reference: wp theme command.

6. Export and Import the Database

Database export and import commands are essential for migrations, backups, staging refreshes, and local development.

wp db export backup.sql
wp db import backup.sql
wp db check
wp db repair
wp db optimize

Useful examples:

# Export database
wp db export before-update.sql

# Import database
wp db import staging.sql

# Check database tables
wp db check

# Repair database tables
wp db repair

# Optimize database tables
wp db optimize

Safety note:

wp db import overwrites the current database with the imported SQL file. On WooCommerce, LMS, booking, or membership sites, importing an old database can remove recent orders, users, subscriptions, bookings, or form entries.

Official reference: wp db command.

7. Run Search-Replace Safely During Migrations

wp search-replace is one of the most important WP-CLI commands for WordPress migrations. It replaces URLs or text inside the database while handling serialized data more safely than a basic SQL find-and-replace.

Basic usage:

wp search-replace 'https://oldsite.com' 'https://newsite.com'

Always test first with dry run:

wp search-replace 'https://oldsite.com' 'https://newsite.com' --dry-run

Skip GUID column when appropriate:

wp search-replace 'https://oldsite.com' 'https://newsite.com' --skip-columns=guid

Export transformed SQL instead of changing the live database:

wp search-replace 'https://oldsite.com' 'https://newsite.com' --export=updated-database.sql

When to use this:

  • Changing domain names.
  • Moving from staging to production.
  • Switching from HTTP to HTTPS.
  • Moving from temporary URLs to live URLs.
  • Fixing hardcoded URLs after migration.

Safety warning:

Search-replace can permanently change large parts of your database. Always export the database first and run --dry-run before applying the real command.

Official reference: wp search-replace command.

8. Flush Cache and Object Cache

Cache commands are useful after migrations, plugin changes, object cache issues, and debugging strange frontend or admin behavior.

wp cache flush
wp cache get key group
wp cache delete key group

Most-used command:

wp cache flush

When to use this:

  • After migration.
  • After search-replace.
  • After changing site URLs.
  • When object cache shows stale data.
  • After plugin/theme update issues.

Developer note:

wp cache flush clears the WordPress object cache. It is not always the same as clearing page cache, CDN cache, or hosting cache. You may still need to clear cache from your performance plugin, hosting panel, or CDN.

Official reference: wp cache command.

9. Flush Rewrite Rules

Rewrite rules control pretty permalinks, custom post type URLs, taxonomies, and many plugin-generated URL structures. If posts, pages, products, or custom post types show 404 errors after a change, flushing rewrite rules can help.

wp rewrite flush

Hard flush:

wp rewrite flush --hard

When to use this:

  • After registering a custom post type.
  • After changing permalink structure.
  • After WooCommerce product permalink issues.
  • After migration when posts show 404.
  • After activating/deactivating plugins that add rewrite rules.

Safety note:

Do not flush rewrite rules on every page load inside plugin code. With WP-CLI, use it manually when needed.

Official reference: wp rewrite command.

10. Manage WordPress Users

User commands are useful for creating admin users, checking roles, resetting passwords, auditing accounts, and emergency access recovery.

wp user list
wp user get admin
wp user create dev dev@example.com --role=administrator
wp user update dev --user_pass='new-strong-password'
wp user delete olduser --reassign=1

Useful examples:

# List administrators
wp user list --role=administrator

# Create a new administrator
wp user create dev dev@example.com --role=administrator

# Reset a user password
wp user update dev --user_pass='new-strong-password'

# Delete a user and reassign content
wp user delete olduser --reassign=1

Security note:

Be careful when creating administrator accounts. Use strong passwords, remove temporary users after support work, and avoid leaving unused admin accounts active.

Official reference: wp user command.

11. Manage Options and Site URLs

The wp option command is useful for checking and updating WordPress settings directly from the terminal.

wp option get siteurl
wp option get home
wp option update siteurl 'https://example.com'
wp option update home 'https://example.com'
wp option list --autoload=on

When to use this:

  • Fixing wrong site URLs after migration.
  • Checking whether staging points to the right domain.
  • Auditing autoloaded options.
  • Updating settings when wp-admin is inaccessible.

Migration example:

wp option update siteurl 'https://newdomain.com'
wp option update home 'https://newdomain.com'

Official reference: wp option command.

12. Manage Transients

Transients are temporary cached values stored by WordPress and plugins. Old or broken transients can cause stale data, odd plugin behavior, or database clutter.

wp transient list
wp transient get transient_name
wp transient delete transient_name
wp transient delete --all
wp transient delete --expired

Useful examples:

# Delete expired transients
wp transient delete --expired

# Delete all transients
wp transient delete --all

When to use this:

  • After plugin settings behave strangely.
  • After migration.
  • When cached API responses are stale.
  • During database cleanup.

Safety note:

Deleting transients is usually safe, but it can temporarily slow the next page load as plugins rebuild cached data.

Official reference: wp transient command.

13. Manage WP-Cron Events

WP-Cron controls scheduled tasks such as publishing scheduled posts, plugin jobs, WooCommerce scheduled actions, email queues, backups, imports, and update checks.

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

Useful examples:

# List scheduled cron events
wp cron event list

# Run due cron events now
wp cron event run --due-now

# List available cron schedules
wp cron schedule list

When to use this:

  • Scheduled posts are not publishing.
  • Emails or plugin jobs are delayed.
  • WooCommerce scheduled actions pile up.
  • Backups or imports are stuck.
  • Admin dashboard is slow due to background tasks.

Official reference: wp cron command.

14. Regenerate Media Thumbnails

When a theme changes image sizes, existing media may need new thumbnails. WP-CLI can regenerate thumbnails without relying on a web-based process.

wp media regenerate
wp media regenerate --yes
wp media image-size

Useful examples:

# Show registered image sizes
wp media image-size

# Regenerate all thumbnails
wp media regenerate --yes

When to use this:

  • After changing theme image sizes.
  • After switching themes.
  • After WooCommerce product image size changes.
  • After migration when thumbnails are missing.

Performance note:

Regenerating media on a large site can use heavy CPU and disk resources. Run it during a quiet period or in batches if needed.

Official reference: wp media command.

15. Use Maintenance Mode During Updates

Maintenance mode commands are useful during controlled update windows, migrations, and deployment work.

wp maintenance-mode activate
wp maintenance-mode status
wp maintenance-mode deactivate

Example workflow:

wp maintenance-mode activate
wp db export before-maintenance.sql
wp plugin update --all
wp theme update --all
wp core update
wp core update-db
wp cache flush
wp maintenance-mode deactivate

When to use this:

  • Plugin/theme update windows.
  • Core updates.
  • Database imports.
  • Migrations.
  • Emergency recovery work.

Official reference: wp maintenance-mode command.

16. Scaffold Plugins, Blocks, and Code Faster

The wp scaffold command helps developers generate starter code for plugins, post types, taxonomies, blocks, child themes, and tests.

wp scaffold plugin my-plugin
wp scaffold post-type book --plugin=my-plugin
wp scaffold taxonomy genre --post_types=book --plugin=my-plugin
wp scaffold child-theme my-child-theme --parent_theme=twentytwentysix
wp scaffold block my-block --theme

When to use this:

  • Starting a custom plugin.
  • Creating boilerplate for custom post types.
  • Creating a child theme.
  • Building blocks and testable plugin structures.
  • Speeding up repeatable development work.

Official reference: wp scaffold command.

17. Debug Performance With WP-CLI Profile

The wp profile command helps identify what is slow in WordPress. It is useful when a site loads slowly but the cause is not obvious.

wp profile stage
wp profile hook
wp profile eval 'is_admin();'

When to use this:

  • Finding slow plugins or hooks.
  • Debugging slow admin pages.
  • Investigating bootstrap performance.
  • Comparing staging vs production behavior.

Developer note:

wp profile is for diagnosis. Use it with logs, Query Monitor, slow query logs, and real server metrics for a full performance picture.

FyrePress tool: If you have PHP, server, or slow request logs, use the FyrePress Server Log Analyzer to classify the likely cause.

18. Work With Multisite Commands

WP-CLI is very useful for WordPress multisite because many tasks are painful through the dashboard.

wp site list
wp site create --slug=newsite --title="New Site"
wp site delete 3
wp super-admin list
wp super-admin add username

Run commands for a specific site:

wp option get siteurl --url=https://subsite.example.com
wp plugin list --url=https://subsite.example.com

When to use this:

  • Managing agency multisite networks.
  • Checking plugin status per subsite.
  • Creating new subsites.
  • Running search-replace across a network.
  • Auditing users and super admins.

Safety note:

Multisite search-replace and delete operations can affect many sites. Use --dry-run, specify --url, and back up first.

19. Check Registered Post Types, Roles, and Capabilities

When debugging custom plugins, membership sites, LMS systems, and custom post type workflows, WP-CLI can quickly show registered data.

wp post-type list
wp post-type get product
wp role list
wp cap list administrator
wp cap add editor edit_theme_options
wp cap remove editor edit_theme_options

When to use this:

  • Debugging missing custom post types.
  • Checking WooCommerce product registration.
  • Auditing custom roles.
  • Fixing permission problems.
  • Testing membership or LMS role behavior.

Safety note:

Do not add powerful capabilities to roles casually. Changing capabilities can create security issues if editors or customers get permissions they should not have.

20. Use wp eval Carefully

wp eval lets you run PHP inside the WordPress context. It is powerful for quick checks, but it should be used carefully because it can run arbitrary code.

wp eval 'echo get_bloginfo("name");'
wp eval 'var_dump( wp_get_environment_type() );'
wp eval 'echo wp_upload_dir()["basedir"];'

When to use this:

  • Checking WordPress values quickly.
  • Testing helper functions.
  • Debugging environment variables.
  • Inspecting upload paths or options.

Safety warning:

Never paste random wp eval commands from unknown sources into production. It runs PHP with WordPress loaded and can alter or destroy data if misused.

Official reference: wp eval command.

Useful WP-CLI Workflows for Developers

Pre-update backup and update workflow

wp db export before-update.sql
wp plugin list --update=available
wp theme list --update=available
wp core check-update
wp maintenance-mode activate
wp plugin update --all
wp theme update --all
wp core update
wp core update-db
wp cache flush
wp maintenance-mode deactivate

Migration workflow

wp db export production.sql
wp db import production.sql
wp search-replace 'https://oldsite.com' 'https://newsite.com' --dry-run
wp search-replace 'https://oldsite.com' 'https://newsite.com' --skip-columns=guid
wp cache flush
wp rewrite flush --hard

Emergency plugin recovery

wp plugin list
wp plugin deactivate problematic-plugin
wp cache flush

Admin access recovery

wp user list --role=administrator
wp user create emergency emergency@example.com --role=administrator
wp user update emergency --user_pass='strong-temporary-password'

Slow dashboard investigation

wp cron event list
wp transient delete --expired
wp option list --autoload=on
wp plugin list --status=active
wp profile stage

Commands to Be Extra Careful With

Some WP-CLI commands are powerful enough to cause real damage if used incorrectly.

Command Risk Safer Practice
wp db import Overwrites current database Export current database first
wp search-replace Mass changes database content Use --dry-run first
wp user delete Can remove users and content ownership Use --reassign
wp plugin update --all Can break compatibility Test on staging first
wp theme activate Can change frontend layout Use during controlled testing
wp eval Runs arbitrary PHP Run only code you understand
wp db reset Deletes all database tables Avoid on production

Best WP-CLI Commands by Developer Type

For freelance WordPress developers

Learn wp plugin, wp theme, wp db export, wp search-replace, wp user, and wp rewrite flush. These cover most client maintenance and migration work.

For agency developers

Add wp site, wp cron, wp profile, wp option, and scripted update workflows. These help when managing many sites.

For WooCommerce developers

Focus on database exports, cron events, scheduled actions through WooCommerce tooling, plugin updates, user commands, and cache flushing. Be careful with database imports because order data changes constantly.

For theme developers

Learn wp theme, wp media regenerate, wp scaffold child-theme, wp rewrite flush, and wp option.

For plugin developers

Learn wp scaffold plugin, wp eval, wp cron, wp db, wp option, wp post-type, wp role, and wp cap.

WP-CLI Best Practices

  • Always confirm the current site before running commands.
  • Export the database before destructive operations.
  • Use --dry-run when available.
  • Run risky updates on staging first.
  • Use maintenance mode for production update windows.
  • Document commands used during migrations.
  • Do not run copied commands you do not understand.
  • Be careful with multisite network-wide commands.
  • Use strong temporary passwords and remove emergency users later.
  • Do not leave debug or profiling tools active longer than needed.

Final Recommendation

Every WordPress developer should know WP-CLI basics in 2026. You do not need to memorize every command, but you should be comfortable with core updates, plugin/theme management, database exports/imports, safe search-replace, cache flushing, rewrite flushing, cron debugging, user management, option checks, transient cleanup, and media regeneration.

The biggest advantage of WP-CLI is not just speed. It gives you repeatable workflows. Once you can turn a migration, update, backup, or recovery task into a reliable set of commands, you save time and reduce dashboard-click mistakes.

Start with the safe commands, build your own checklist, and always back up before running anything that changes the database.

Frequently Asked Questions

What is WP-CLI used for?

WP-CLI is used to manage WordPress from the command line. Developers use it for updates, backups, migrations, plugin management, user management, database operations, cron debugging, cache flushing, and automation.

What is the most important WP-CLI command for migrations?

wp search-replace is one of the most important migration commands because it updates URLs and text in the database while handling serialized data better than basic SQL replacement. Use --dry-run first.

How do I back up a WordPress database with WP-CLI?

Use wp db export backup.sql to export the database to an SQL file. Run it before updates, imports, search-replace operations, and major maintenance work.

Can WP-CLI update plugins?

Yes. Use wp plugin update plugin-slug to update one plugin or wp plugin update --all to update all plugins. Test on staging first for business-critical sites.

Can WP-CLI fix WordPress 404 errors?

WP-CLI can help fix permalink-related 404 errors by flushing rewrite rules with wp rewrite flush. If the issue is caused by missing content or bad redirects, additional troubleshooting is needed.

Can WP-CLI create an admin user?

Yes. Use wp user create username email@example.com --role=administrator to create a new administrator account. Remove temporary admin users after support or recovery work.

Is WP-CLI safe on production websites?

WP-CLI is safe when used carefully, but some commands can be destructive. Always confirm the site, back up the database, use staging for risky changes, and test commands with --dry-run where available.

Can WP-CLI manage WordPress multisite?

Yes. WP-CLI includes multisite commands such as wp site list, wp site create, and wp super-admin. Use --url carefully when targeting specific subsites.

What command clears WordPress cache in WP-CLI?

Use wp cache flush to clear the WordPress object cache. This may not clear hosting cache, page cache, CDN cache, or plugin-specific cache.

What WP-CLI command helps debug scheduled tasks?

Use wp cron event list to view scheduled events and wp cron event run --due-now to run due cron events. This helps debug delayed jobs, scheduled posts, and plugin tasks.