So dynamically set WP_SITEURL, WP_HOME, i override the wp-config as
define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] );
define('WP_HOME', 'http://' . $_SERVER['SERVER_NAME'] );
but when i call home_url() it always return x.co.uk hostname
home_url()
does not make use of any WordPress constants. It uses a call to get_option( 'home' )
. To use WP_HOME instead, short circuit get_option()
:
add_filter( 'pre_option_home', 'wpse_114486_change_get_option_home' );
/**
* Change get_option( 'home' ) and any functions that rely on it to use
* the value of the WP_HOME constant.
*
* This is not fully tested. Many WordPress functions depend on the value of
* get_option( 'home' ). The ramifications of this filter should be tested
* thoroughly.
*/
function wpse_114486_change_get_option_home( $option ) {
if ( defined ( 'WP_HOME' ) )
return WP_HOME;
return false;
}