Site logo

Archived topic

Duplicate logo in homepage

13 replies · Started by Yerai on March 20, 2023

Viewing posts 1–14 of 14

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!

Sure, URL is protected by password at server level. I'll let you access in the private field.

Thank you Leo!

Done leo, the two logos are still there, but certainly that pieces of code wasn't needed.

Hi 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:

https://docs.generatepress.com/article/generate_logo/

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 :')

It works nicely! Thank you Leo :)

No problem :)

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!

Try 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' ) ) )
    );
} );

Awesome David, that did wonders! :)

Thank you all for your great support!

You're welcome

This archived topic is closed to new replies.