Useful WP-CLI Commands Every WordPress Developer Should Know

September 10, 2026

I still remember the nightmare client call. A plugin update had thrown a fatal PHP error across a WooCommerce site, killing the admin dashboard entirely. I had no FTP credentials saved on my laptop, and the host control panel was loading like molasses. I SSHed into the server, typed a single command to deactivate the offending plugin, and restored the site in less than five seconds. That was the day I stopped clicking around the WordPress dashboard and fully embraced the command line.

If you build or manage sites for a living, relying purely on the graphical interface is like driving a sports car in first gear. You can get where you are going, but it is slow, tedious, and prone to breaking when things go sideways. Learning a solid useful wp-cli commands list changes everything. It turns complex, repetitive database tasks and site setups into instantaneous, single-line commands.

Whether you are setting up a fresh local environment, troubleshooting a crashed site, or managing dozens of client installations, mastering essential wordpress command line tools will save you hundreds of hours every year. Let us walk through the exact commands I rely on daily, along with a few lessons I learned the hard way so you do not have to.

Setting Up WordPress in Seconds Instead of Minutes

Remember downloading the WordPress zip file, extracting it, creating a MySQL database in phpMyAdmin, and filling out the famous five-minute installation form? WP-CLI turns that whole process into a ten-second script. When I am setting up a clean sandbox, I do not open a web browser at all.

First, you download the core files directly into your project directory:

wp core download

Next, generate your wp-config.php file without touching a text editor. You pass your database credentials right through the terminal:

wp config create --dbname=devdb --dbuser=root --dbpass=root

Finally, run the installation script directly from the terminal. This sets up the database tables, creates your admin account, and assigns your site URL instantaneously:

wp core install --url=example.test --title='Dev Site' --admin_user=admin --admin_password=securepassword --admin_email=admin@example.test

If you are building sites locally on a regular basis, pairing this workflow with a proper local WordPress development environment is absolute magic. You can chain these commands into a simple bash script and deploy a fresh development site in the time it takes to sip your coffee.

Managing Plugins and Themes Without Touching the Admin Dashboard

The dashboard interface works fine until a bad update locks you out, or you need to bulk-install twenty tools across ten different client sites. WP-CLI makes managing your extensions painless and insanely fast.

To install and activate a plugin from the WordPress repository in a single swing, run:

wp plugin install query-monitor --activate

If a broken plugin drops the white screen of death on your site, you do not need to hunt down files in cPanel. You can inspect all installed plugins and their current status right away:

wp plugin list

Then deactivate the problematic plugin instantly:

wp plugin deactivate broken-plugin-slug

Here are a few quick plugin and theme operations I execute every single week:

  • Update everything at once: wp plugin update --all
  • Search the repository: wp plugin search seo
  • Activate a custom theme: wp theme activate my-custom-theme
  • Force-delete an stubborn plugin: wp plugin delete unwanted-plugin

Early in my career, I once accidentally deleted a custom parent theme on a live production site because I ran a delete command without checking active theme dependencies. Always double-check your active theme status using wp theme list before purging old theme folders!

Database Search and Replace (The Safe Way)

Migrating a site from a staging URL like staging.example.test to a live domain like example.com used to be a terrifying operation. Because WordPress stores serialized data inside the database, a plain SQL search and replace will corrupt your widgets, theme settings, and page builder layouts.

WP-CLI solves this elegant problem with its built-in search-replace engine, which safely unpacks serialized strings, updates the URLs, and repacks them cleanly.

wp search-replace 'http://staging.example.test' 'https://example.com'

Before you run this on a live database, always use the --dry-run flag. This simulates the entire process and shows you exactly how many table rows and strings will be modified without writing any actual changes to the database:

wp search-replace 'http://staging.example.test' 'https://example.com' --dry-run

I learned the value of dry runs the hard way. I once accidentally replaced a partial string that matched internal system paths, breaking media uploads across thousands of posts. Now, I never run a search-replace command without checking the dry run results first. If you regularly work on custom database tables or custom fields, combining this tool with custom code setups like learning how to customize WooCommerce with code makes domain migrations completely painless.

Database Backups and Maintenance from the Command Line

Before modifying core code, pushing updates, or testing new features, creating a fresh database export is non-negotiable. Loading up phpMyAdmin or installing heavy backup plugins just to grab an SQL dump takes unnecessary time and server resources.

You can dump your entire database into a single file in one second:

wp db export backup-db.sql

If you break something during testing, restoring that exact database dump is just as fast:

wp db import backup-db.sql

Need to run a quick optimization on fragmented database tables? Forget bloated database cleaner plugins. Just run:

wp db optimize

For developers who track their code using control systems, combining fast database dumps with clean repositories is essential. Take a look at our guide on how to use Git and version control for WordPress development to build a bulletproof deployment pipeline alongside your CLI commands.

User Management and Emergency Access Recovery

We have all had a client lock themselves out of their admin account, or forget their credentials right before a launch. Instead of going through password reset emails that get caught in spam filters or editing MD5 hashes manually in database tables, WP-CLI lets you fix access issues instantly.

To create a brand-new administrator account immediately:

wp user create developer dev@example.com --role=administrator --user_pass=SuperSecurePass123!

If you just need to reset the password for an existing user account:

wp user update clientusername --user_pass=NewPassword456!

You can also list all registered users to see who has administrative privileges on a compromised or inherited site:

wp user list --role=administrator

If you are customizing authentication flows or building custom client portals, managing users via CLI saves massive amounts of manual testing time. You can even check out how to create a custom WordPress login page to pair seamless backend user control with a polished front-end brand experience.

Clearing Cache and Debugging Live Performance Issues

Caching issues cause huge headaches during active development. You push a visual change or update a script, but nothing happens because the object cache, transient data, or page cache is still holding onto old assets.

You can flush the WordPress object cache completely with one command:

wp cache flush

If transient data stored in the options table is causing stale API calls or broken layout states, clear them all out safely:

wp transient delete --all

When troubleshooting performance bottlenecks or slow queries, running a diagnostic check on your site’s speed is crucial. I recommend running our free website speed test tool before and after clearing out database junk and transients to measure real load-time improvements.

If you are hunting down site slowdowns, you can also run our automated WordPress speed self-audit to pinpoint exactly which scripts or database queries are dragging down your performance scores.

Common Mistakes to Avoid with WP-CLI

While WP-CLI is an incredible productivity tool, executing commands with root privileges or without proper precautions can cause serious damage fast. Here are the most frequent mistakes I see developers make:

  • Running commands as the root server user: WP-CLI actively warns you against running commands as system root because it can mangle file permissions across your web server. Always run commands as your web user (like www-data or your cPanel username).
  • Skipping dry runs on search-replace: Never execute a global search and replace across a live production site without verifying the scope using --dry-run first.
  • Forgetting to specify the site path: When running commands on multi-site networks or servers with multiple installations, always use the --path=/var/www/html flag to ensure you are modifying the correct site.
  • Not backing up before bulk updates: Running wp plugin update --all on a live site without an immediate wp db export beforehand is playing high-stakes roulette with your uptime.

Supercharging Your WordPress Workflow

Adding these command line tools to your daily routine takes a bit of initial muscle memory, but the payoff is massive. Tasks that used to eat up twenty minutes of clicking, waiting for page reloads, and dealing with slow hosting panels now take literally two seconds in your terminal window.

Start small. Pick two or three basic commands—like updating plugins or clearing your object cache—and start using them today. Once you feel the speed difference, you will naturally start using terminal scripts for full site migrations, user creation, and local setups.

Got a favorite custom bash script or a WP-CLI trick that saved your skin on a project? Drop a comment or reach out—I am always excited to trade terminal tips with fellow developers!

Focused view of programming code displayed on a laptop, ideal for tech and coding themes.
Focused view of programming code displayed on a laptop, ideal for tech and coding themes.
Vivid close-up of code on a computer screen showcasing programming details.
Vivid close-up of code on a computer screen showcasing programming details.

2 thoughts on “Useful WP-CLI Commands Every WordPress Developer Should Know”

Leave a Comment