Archived topic
Custom logo on different pages
3 replies · Started by Michael on July 12, 2022
Hi
I did the following successfully in the past, maybe I am doing something wrong this time.
Goal is to have a different logo for specific pages.
// Decide when to display the positive or negative logo
add_filter( 'generate_logo','mh_custom_about_logo' );
function mh_custom_about_logo( $logo )
{
// If we are on the feed page, set our custom logo
if ( is_page( 'feed-2' ) )
return '/wp-content/uploads/2022/07/custom-logo.png';
// Or else, set the regular logo
return $logo;
}
But it does not work for some reason - do you see the issue?
Thanks a lot,
Michael
Hi Michael,
Have you considered using the Site Logo option with in the merged header element you are using?
https://docs.generatepress.com/article/transparent-header-and-navigation/
That should work for most cases.
The video in the documentation should be helpful.
Let me know :)
Hi Leo
Thanks a lot, that worked.
However, I am still wondering why the code above does not work. Seems weird to me as I cannot see an issue there.
Cheers,
Michael
Hi Michael,
It should work. Are you using a retina logo? If so, you’ll need to replace the retina logo as well through generate_retina_logo filter.
Example:
add_filter( 'generate_retina_logo','mh_custom_about_logo' );
function mh_custom_about_logo( $logo )
{
if ( is_home() ) {
$logo = 'https://fazarcon.pluginsupportwp.com/wp-content/uploads/2022/06/medium.jpg';
return $logo;
}
return $logo;
}
Try placing the entire image URL.
Kindly let us know how it goes.