Archived topic
change logo image on one page
8 replies · Started by Rob on July 28, 2021
Hi,
I've used some custom CSS (using page-id targetting) to change the background color of the navigation bar on a homepage (https://www.yaronengler.com/home/), but is there a way to also change the logo image on this page?
Standard navigation (colors, logo, etc) are all fine on other pages (eg: https://www.yaronengler.com/programme/), but I'd like the logo to be white just on https://www.yaronengler.com/home/
Thanks
Rob
Hi there,
it requires some PHP to do that - and to use the generate_logo filter
https://docs.generatepress.com/article/generate_logo/
Your code would be something like this:
add_filter( 'generate_logo', function( $logo ) {
// Return our category logo URL
if ( is_page( 42 ) ) {
return 'URL TO YOUR PAGE LOGO';
}
// Otherwise, return our default logo
return $logo;
} );
Change the 42 to match the ID of your Page ( which can be found when editing the Page, check the URL in the browser ).
And add the full URL to the image where it says: URL TO YOUR PAGE LOGO
This article explains adding PHP:
Thanks David - works perfectly!
https://www.yaronengler.com/home/
Glad to hear that!
Hi David,
I tried the above solution but it is not working for me to change the logo for a particular page.
Is it because I have Header Layout set as "Use Navigation as Header"?
Thanks.
Ok so I tried using the Header Element with the Display Rules set for a specific page and it shows a different logo for that page but I also want a different sticky logo for that page, how do I achieve that? Thanks.
Any chance you can open a new topic and link us to the page in question?
Thanks!
Hi Leo,
Created a new topic - https://generatepress.com/forums/topic/change-header-and-sticky-logo-image-on-one-page/
Unfortunately I cannot share the link.
Thanks
Thanks!