I discovered this handy feature when troubleshooting a login problem for a client of mine.

If you swap your WP database between your local development and production server at all regularly — and don’t fancy editing your site URL and WordPress URL in the wp-options table each time (either directly or via the WP admin interface) — you can hard code it into the wp-config.php file! Tie this together with WordPress ability to keep this config file out of harms way in a directory above your WP install (ie out of your public_html directory) and you have an easy hands free file sync operation too.

Just add these two lines of code into wp-config.php:

// hardcoding the domain
define("WP_SITEURL","http://www.mysite.com");
define("WP_HOME","http://www.mysite.com");

BTW – note the lack of trailing slashes on the URLs

Last updated on 5th September 2018