Archived topic
Change Header logo based on site URL
3 replies · Started by Marcel on September 25, 2019
Hi:
I have one WP site and 3 primary domain names pointing to it.
For domainA.com, I want to display https://domaina.com/wp-content/uploads/01/01/domaina-logo.png as the logo
For domainB.com, I want to display https://domaina.com/wp-content/uploads/01/01/domainb-logo.png as the logo
For domainB.com, I want to display https://domaina.com/wp-content/uploads/01/01/domainc-logo.png as the logo
I have removed the site logo from the Customizer and created a child-theme with the following code in it:
function change_logo_of_site($logo_url){
$logo_url = $logo_url;
$home = home_url();
$home = $_SERVER['HTTP_REFERER'];
if($home=='https://domainA.com/'){
$logo_url = 'https://domaina.com/wp-content/uploads/01/01/domaina-logo.png';
}
if($home=='https://domainB.com/'){
$logo_url = 'https://domaina.com/wp-content/uploads/01/01/domainb-logo.png';
}
if($home=='https://domainC.com/'){
$logo_url = 'https://domaina.com/wp-content/uploads/01/01/domainc-logo.png';
}
return $logo_url;
}
add_filter('generate_logo','change_logo_of_site',10,1);
This is not working.
I've attempted to place this code into the Appearance > GP Hooks > wp_head area as PHP as well, but no luck.
Can anyone shed light on this for me?
Hi there,
What about this?:
add_filter( 'generate_logo', function( $logo_url ) {
$home = $_SERVER['HTTP_HOST'];
if ( strpos( $home, 'domainA.com') !== false ){
$logo_url = 'LOGO URL HERE';
}
if ( strpos( $home, 'domainB.com') !== false ){
$logo_url = 'LOGO URL HERE';
}
if ( strpos( $home, 'domainC.com') !== false ){
$logo_url = 'LOGO URL HERE';
}
return $logo_url;
} );
Let me know :)
Wonderful, that worked perfectly!
Thanks
You're welcome :)