WordPress – Changing The Site URL Using WP-CLI Command Line Tool

Published

The WP-CLI command line tool is a handy application to run various WordPress tasks.

Download the WP-CLI command line tool into the WordPress root folder using CURL or WGET.

[bash]
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
[/bash]

Check if the tool is working.

[bash]
php wp-cli.phar –info
[/bash]

Not run the search and replace command to look through all the core tables to change the URL.

[bash]
php wp-cli.phar search-replace ‘http://www.olddomain.com’ ‘http://www.newdomain.com’
[/bash]

This will save you numerous hours and give you some peace of mind!