filters – How to redirect template_directory to subdomain relativ url?
Question
I use subdomains with the same template and I try to use filter template_directory to replace serverName by $_SERVER['HTTP_HOST']
but it doesn’t work .
The relative url used by get_template_directory
is still the same as default using filter – the subdomain isn’t added :
add_filter( 'template_directory', function( $template_dir ){
$subdomain = 'https://' . $_SERVER['HTTP_HOST'];
return str_replace( 'https://website.com', $subdomain , $template_dir_uri );
});
I should get https://subdomain.website.com
0
1 year
2022-07-28T08:58:54-05:00
2022-07-28T08:58:54-05:00 0 Answers
0 views
0
Leave an answer