How to change a Wordpress site URL

Sometimes you may need to change the URL of your WordPress site.

For example, it is a common practice to develop the new version of your site in a subfolder and when it is ready to move it into your root directory.

WordPress, however, relies on its URL settings to work correctly.

This means that if you simply move your files and database it will not work properly.

The URL settings are located in the application database. Fortunately, direct database modification can be avoided by using a nice function provided by the WordPress developers named "update_option".

Simply add these lines to the functions.php file of your theme:

update_option('siteurl','http://www.new-site-address.com');
update_option('home','http://www.new-site-address.com');

Then simply load your site from its new location - it should work just fine.

Note that after you run your site once and you make sure it works you should delete those lines from your functions.php file. The settings are already stored in your database and should not be modified each time your site is loaded.

WordPress is a trademark of WordPress Foundation. SiteGround is not affiliated with or endorsed by the WordPress Project or its trademark owners.