- This topic has 13 replies, 3 voices, and was last updated 2 years, 6 months ago by
David.
-
AuthorPosts
-
March 20, 2023 at 11:14 am #2574590
Yerai
Hello GeneratePress Team!
For a site we are currently building, we used the “Feather” prebuilt template from the site library. I don’t know if it’s relevant or not, but I just wanted to let you know, in case it is.
We wanted to show a different logo only in the homepage. So, as site logo, we set in the customizer the logo that we would use in every page (but homepage).
To show a different logo in the homepage, we used one of the header elements the Feather site template uses (called “Merge header/Front page logo”). But thing is in the homepage both logo images are loading as two html div elements.
One has the class “site-logo” and the other “site-logo page-hero -logo”.
We currently have hidden the “site-logo” element visually, but we would like to prevent it to show up in the source code, just in the homepage.
So I’m wondering if there is a way to do that.
Thank you in advance!
March 20, 2023 at 11:58 am #2574635Leo
StaffCustomer SupportHi there,
Any chance you can link us to the page in question?
You can use the private information field:
https://docs.generatepress.com/article/using-the-premium-support-forum/#private-informationLet me know 🙂
March 20, 2023 at 1:09 pm #2574726Yerai
Sure, URL is protected by password at server level. I’ll let you access in the private field.
Thank you Leo!
March 20, 2023 at 6:05 pm #2574845Leo
StaffCustomer SupportCan you remove these two CSS snippets you’ve added first?
https://www.screencast.com/t/kB0QKBJqThThey conflict with each other and shouldn’t be needed.
March 21, 2023 at 4:21 am #2575378Yerai
Done leo, the two logos are still there, but certainly that pieces of code wasn’t needed.
March 21, 2023 at 7:07 am #2575570David
StaffCustomer SupportHi there,
when you have a merged Header Element Logo, it doesn’t remove the site identity logo, it just hides it with CSS.
Is the issue – that you want to remove its HTML ?If so, then instead of using the header element to swap the logo you can use a PHP Snippet – see here:
March 21, 2023 at 11:04 am #2575981Yerai
Yeah, that’s right David, I want to remove the HTML.
How can I remove it only in the homepage? I guess it may be easy, but I’m a totally noob at PHP :’)
March 21, 2023 at 11:27 am #2576000Leo
StaffCustomer SupportTry this:
add_filter( 'generate_logo', function( $logo ) { // Return our category logo URL if ( is_front_page() ) { return 'URL TO YOUR FRONT PAGE LOGO'; } // Otherwise, return our default logo return $logo; } );
Reference: https://codex.wordpress.org/Conditional_Tags#The_Main_Page
March 21, 2023 at 11:49 am #2576025Yerai
It works nicely! Thank you Leo 🙂
March 21, 2023 at 5:49 pm #2576236Leo
StaffCustomer SupportNo problem 🙂
March 22, 2023 at 6:19 am #2576781Yerai
I’ve found out that the logo is not replaced in the sticky navigation. I’ve looked in the filter collection for one filter that could help me replacing the sticky logo without success.
What filter can I use to achieve that?
Thanks again!
March 22, 2023 at 7:36 am #2576852David
StaffCustomer SupportTry this:
add_filter( 'generate_sticky_navigation_logo_output', function($logo) { if ( !is_front_page() ) { return $logo; } return sprintf( '<div class="sticky-navigation-logo"> <a href="%1$s" title="%2$s" rel="home"> <img src="your_logo_url" class="is-logo-image" alt="alt name" width="100" height="100" /> </a> </div>', esc_url( apply_filters( 'generate_logo_href', home_url( '/' ) ) ), esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ) ); } );
March 22, 2023 at 7:41 am #2576860Yerai
Awesome David, that did wonders! 🙂
Thank you all for your great support!
March 22, 2023 at 8:05 am #2577032David
StaffCustomer SupportYou’re welcome
-
AuthorPosts
- You must be logged in to reply to this topic.