Wildcard Subdomain – Override get_site_url()
-
I have a site that uses wildcard subdomains. Enter www. or wwg. or whateve and the site works – only on the first visit. If a user visits a second page they are taken to the www version because of the URL in the menu’s displaying the absolute path that is built using the get_site_url().
I am trying to add a filter to over ride the built in get_site_url() function. The filter to the last line of the functions file.
Also for this to work you need wildcard subdomains set up – which I have.
Any ideas why this isnt working ?
function set_site_subdomain() {
$server_name = $_SERVER[‘SERVER_NAME’] ;
$host = explode(‘.’, $server_name );
$this_subdomain = $host[0];$site_url_array = explode(“.”, get_site_url() ) ;
$new_url = “https://”.$this_subdomain.”.”.$site_url_array[1].”.”.$site_url_array[2] ;
return $new_url ;
}
add_filter(‘get_site_url’, ‘set_site_subdomain’, 1 );
Thanks in advance
- The topic ‘Wildcard Subdomain – Override get_site_url()’ is closed to new replies.