Cookbook › WP-CLI
Replace an old address everywhere with WP-CLI
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.
What happens
Section titled “What happens”- Your assistant runs
wp search-replace http://old.example.com https://example.com --dry-runand reports what would change. - After your go, it runs the same command without
--dry-run. Serialized settings are updated safely. - On a large site it works in batches and carries on where the last batch ended.
Try also
Section titled “Try also”- “Change our old phone number 020 1234 5678 to 020 8765 4321 everywhere.”
- “How many posts mention ‘summer sale’? Use wp db query.”
Good to know
Section titled “Good to know”- 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.