How to set dynamic `home` and `siteurl` in WordPress?
PHP Snippet 1:
//presumes server is set up to deliver over https
define('WP_SITEURL', 'https://' . $_SERVER['HTTP_HOST']);
define('WP_HOME', 'https://' . $_SERVER['HTTP_HOST']);
PHP Snippet 2:
require_once(ABSPATH . 'wp-settings.php');
PHP Snippet 3:
function replace_siteurl($val) {
return 'http://'.$_SERVER['HTTP_HOST'];
}
add_filter('option_siteurl', 'replace_siteurl');
add_filter('option_home', 'replace_siteurl');