How to do better search replace with SSH using WP-CLI - Brown Surfing

How to do better search replace with SSH using WP-CLI

Posted on: August 10th, 2022
By: Efrain Lemus

wp search-replace 'http://example.dev' 'http://example.com' --precise --recurse-objects --all-tables

Here’s the WordPress documentation on the wp search-replace command.

You can also check the site/home URL

wp option get siteurl

To set the site URL, run the following command

wp option set siteurl "new-url"

To set the home URL, run the following command

wp option set home "new-url"

Don’t forget to flush the cache

wp cache flush

The site and home URLs usually go hand-in-hand when you run them together.

Have any questions or comments? Write them below!


Leave a Reply

Your email address will not be published. Required fields are marked *