Skip to content

Cookbook › WP-CLI

Replace an old address everywhere with WP-CLI

WP-CLI2 minutesChangesTested 15 Oct 2026
Paste into ChatGPT or ClaudeUse WP-CLI to do a dry run of replacing http://old.example.com with https://example.com. Tell me how many places would change, and wait for my go.

Changes your site. Standard asks you first in wp-admin; Trusted does it directly.

  1. Your assistant runs wp search-replace http://old.example.com https://example.com --dry-run and reports what would change.
  2. After your go, it runs the same command without --dry-run. Serialized settings are updated safely.
  3. On a large site it works in batches and carries on where the last batch ended.
  • “Change our old phone number 020 1234 5678 to 020 8765 4321 everywhere.”
  • “How many posts mention ‘summer sale’? Use wp db query.”
  • Make a backup first (see Back up your site first). A replacement across the whole site can’t be undone with a click.
  • Covers posts, comments, terms and settings, not plugins’ own tables.