Skip to main content
GrN.dk

Main navigation

  • Articles
  • Cases
  • Contact
  • Your Digital Project Manager
  • About Greg Nowak
  • Services
  • Portfolio
  • Container
    • Excel Freelancer
    • Kubuntu - tips and tricks
    • Linux Apache MySQL and PHP
    • News
    • Image Gallery
User account menu
  • Log in

Breadcrumb

  1. Home

WP-CLI Tips and Tricks for Faster WordPress Operations

WP-CLI is still one of the fastest ways to make WordPress maintenance safer, cheaper, and less dependent on one person knowing the right admin screen. For business owners and operations leads, that matters because launches, staging refreshes, access fixes, and plugin cleanup are not special projects. They are repeatable operating tasks. The more repeatable they are, the easier they are to quote, delegate, review, and recover when something goes wrong.

The mistake is using WP-CLI as a pile of clever one-liners. The better model is to treat it as an operations layer with guardrails: make the target environment explicit, choose the smallest command that solves the problem, and rehearse destructive changes before you run them live.

Start by making the target explicit

Most avoidable WP-CLI mistakes are not syntax errors. They are context errors: running the right command against the wrong site. Current WP-CLI global parameters still make this easy to avoid. If you work across multiple installs, multisite, or remote environments, bake the target into the command every time.

wp --path=/var/www/example.com option get home
wp --url=https://client.example.com user list
wp [email protected]:/var/www/example.com plugin list

For multisite, --url is especially important because it defines which site you are acting on. For remote estate management, --ssh remains the cleanest way to run the same operational command against a server or container without inventing a second workflow.

Use option updates for configuration, and search-replace for migrations

A common operational mistake is using full database rewrites when the problem is only a bad site address. If home or siteurl is wrong, update the option values directly and stop there.

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

That is the low-risk fix for configuration drift after a proxy change, domain correction, or incomplete deployment.

When you are actually moving a site or rewriting stored URLs inside content and serialized data, use wp search-replace. The current command docs still make it the right default because it handles serialized data properly and supports dry runs before you commit anything.

wp search-replace 'https://old.example.com' 'https://new.example.com' --skip-columns=guid --dry-run
wp search-replace 'https://old.example.com' 'https://new.example.com' --skip-columns=guid

The familiar --skip-columns=guid pattern still makes sense for standard domain changes. If you need a reviewable artifact before touching production data, WP-CLI also supports exporting rewritten SQL instead of writing straight back to the database. That is a useful middle step for agencies handling larger cutovers or regulated environments.

Handle access fixes and handovers without relying on wp-admin

When a team member loses access, a client handover is delayed, or an admin email needs correcting, CLI is usually faster and more auditable than clicking around in the dashboard. Start by listing users so you are working on the right account, then use the command that matches the actual task.

wp user list
wp user update USERNAME --user_email='[email protected]'
wp user reset-password USERNAME --skip-email --porcelain

wp user update is useful for controlled profile, email, or role changes. For emergency access or handover workflows, the dedicated wp user reset-password command is now the cleaner option. In current WP-CLI docs it supports --skip-email when you do not want an automatic notification, and --porcelain when you need the new password returned in a script-friendly format.

The operational point is simple: access changes should be deliberate, logged, and easy to repeat. Terminal work is not automatically safer, but it is easier to standardize than a verbal “click here, then there” procedure.

Audit plugins before you clean them up

Plugin sprawl is a cost issue as much as a technical issue. Old inactive plugins create noise during audits, complicate updates, and make handovers harder. WP-CLI is still good at turning that cleanup into a reviewable step instead of a guess.

wp plugin list --status=inactive --format=table
wp plugin delete $(wp plugin list --status=inactive --field=name)

The review step matters. Current WP-CLI docs note that wp plugin delete removes plugin files without deactivating or uninstalling them. In practice, that means the command is appropriate for inactive plugins you have already decided to remove, but not for “maybe this is safe” bulk cleanup on client production sites. If you need uninstall routines or vendor-specific cleanup, handle that deliberately before deleting files.

If you also install or activate plugins via CLI, keep that limited to known, approved plugins in controlled environments. The value is not speed for its own sake. The value is making plugin state visible and consistent across staging, QA, and production.

Reserve database resets for disposable environments

WP-CLI database commands remain extremely useful, but this is the area where teams get overconfident fastest. The current database command docs are very clear: wp db reset --yes removes all tables from the database, using the credentials loaded from wp-config.php. That is perfect for local rebuilds, test fixtures, and disposable staging environments. It is not casual production housekeeping.

wp db export before-reset.sql
wp db reset --yes
wp db import wordpress_dbase.sql

If your workflow involves rebuilding a local or staging copy from a known dump, this is efficient and sensible. If the environment is live, customer-facing, or shared with other systems, stop and make sure reset is really the intended operation rather than export, inspect, repair, or search.

Turn the commands into a playbook, not hero knowledge

The biggest commercial benefit of WP-CLI is not that it looks technical. It is that recurring WordPress work can be turned into a standard operating procedure. For most agencies and in-house teams, a good WP-CLI playbook includes:

  • Explicit environment targeting in every risky command.
  • A clear difference between configuration fixes and content migrations.
  • A dry run or review step before destructive changes.
  • A rollback or restore plan for database-level work.
  • A short record of what was run, why, and against which site.

That is what reduces firefighting, improves handovers, and makes WordPress support easier to scope.

If your team has useful WP-CLI knowledge but no consistent operating model around it, Greg can help turn those commands into documented launch, migration, and maintenance workflows that are safer to delegate and easier to support. Talk to Greg about tightening up WordPress operations.

Need help with this kind of work?

Need WP-CLI turned into safer, repeatable WordPress operations for your team? Get in touch with Greg.

Sources

  • wp search-replace – WP-CLI Command
  • wp option update – WP-CLI Command
  • wp user – WP-CLI Command
  • wp plugin – WP-CLI Command
  • wp db – WP-CLI Command
Last modified
2026-06-13

Tags

  • wordpress
  • WP-CLI
  • WordPress operations
  • agency workflows
  • site maintenance

Review Greg on Google

Greg Nowak Google Reviews

 

Illustrated infographic summarizing: Shorter TLS certificates expose every renewal you never automated
Shorter TLS certificates expose every renewal you never automated
2026-07-26

Shorter TLS lifetimes leave less room for manual handoffs and faulty deploy hooks. Build a renewal path that protects service availability.

Illustrated infographic summarizing: One Timeout, Two Orders: Make AI Actions Safe to Retry
One Timeout, Two Orders: Make AI Actions Safe to Retry
2026-07-25

A timed-out AI action may already have succeeded. Stable keys, durable ledgers, queues and stored results prevent a routine retry from duplicating real work.

Illustrated infographic summarizing: Your AI Visibility Dashboard Needs a Methodology, Not More Charts
Your AI Visibility Dashboard Needs a Methodology, Not More Charts
2026-07-24

A practical framework for measuring AI-search visibility with fixed prompts, repeated tests, separate metrics, retained evidence, and honest reporting.

Illustrated infographic summarizing: AI Admin APIs Are Here—But Your Directory Is Still the Source of Truth
AI Admin APIs Are Here—But Your Directory Is Still the Source of Truth
2026-07-23

New AI admin APIs can automate access and spend controls, but reliable governance still starts with authoritative directory data and clear ownership.

Illustrated infographic summarizing: OpenAI Presence Arrived—But Is Your Workflow Ready for an Agent?
OpenAI Presence Arrived—But Is Your Workflow Ready for an Agent?
2026-07-22

Before an AI agent can take on real work, its workflow needs clear scope, permissions, handoffs, evaluation cases, and production monitoring.

Illustrated infographic summarizing: Chatbot Transcripts Quietly Became a Retention and Redaction Problem
Chatbot Transcripts Quietly Became a Retention and Redaction Problem
2026-07-21

Chatbot transcripts spread across providers, logs and support tools. Here is how to map each copy, redact sensitive data and test deletion properly.

Illustrated infographic summarizing: Cloudflare Service Keys Stop in September: Find Every Caller
Cloudflare Service Keys Stop in September: Find Every Caller
2026-07-20

Cloudflare Service Keys stop working on September 30, 2026. Here is how to find every caller, move to scoped API tokens and avoid a late outage.

Illustrated infographic summarizing: Your AI Workflow Needs an Acceptance Test Before It Meets Customers
Your AI Workflow Needs an Acceptance Test Before It Meets Customers
2026-07-19

A practical way to test AI workflows using realistic scenarios, tool checks, human rubrics, regression suites, and clear release gates.

Three cover candidates for The Goats Were Load-Bearing fanned on a dark background: an ember-lit door, three slow knocks, and a founders' ledger
The Goats Were Load-Bearing: a fantasy where the bill always comes due
2026-07-19

A teaser for the upcoming darkly comic fantasy novel The Goats Were Load-Bearing — a village, a door that must stay poor, and the worst possible time to sell the herd. Readers pick the cover.

Vegan Power game: the yellow player catches falling fruit while a chicken and a cow look on
Vegan Power: The Little Game About Eating Fruit, Not Friends
2026-07-19

Vegan Power is a free browser game where you catch fruit, dodge the animals, protect seven hearts, and chase a better high score.

More articles
RSS feed

GrN.dk web platforms, web optimization, data analysis, data handling and logistics.