T-Rex T-Rex - 4 months ago 11
PHP Question

What is best practice to config when changing host in wordpress?

I develop my Wordpress site from the localhost, name: http://moingaytoisong.dev
My real website is : http://moingaytoisong.com
Every time I pull the database from the live site to my local site, I need to search and change the url in wp_options table. It's quite frustrate.
Do you have any better idea?

Answer

In your wp-config.php, just need to add these lines below:

define('WP_HOME','http://moingaytoisong.dev');
define('WP_SITEURL','http://moingaytoisong.dev');

It will overwrite the url in database, so no need to change the url in wp_options anymore. Your local website and your live website can use the same database without any issue