Site logo

[Resolved] Duplicate logo in homepage

Home Forums Support [Resolved] Duplicate logo in homepage

Home Forums Support Duplicate logo in homepage

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #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!

    #2574635
    Leo
    Staff
    Customer Support

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

    Let me know 🙂

    #2574726
    Yerai

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

    Thank you Leo!

    #2574845
    Leo
    Staff
    Customer Support

    Can you remove these two CSS snippets you’ve added first?
    https://www.screencast.com/t/kB0QKBJqTh

    They conflict with each other and shouldn’t be needed.

    #2575378
    Yerai

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

    #2575570
    David
    Staff
    Customer Support

    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/

    #2575981
    Yerai

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

    #2576000
    Leo
    Staff
    Customer Support

    Try 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

    #2576025
    Yerai

    It works nicely! Thank you Leo 🙂

    #2576236
    Leo
    Staff
    Customer Support

    No problem 🙂

    #2576781
    Yerai

    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!

    #2576852
    David
    Staff
    Customer Support

    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' ) ) )
        );
    } );
    #2576860
    Yerai

    Awesome David, that did wonders! 🙂

    Thank you all for your great support!

    #2577032
    David
    Staff
    Customer Support

    You’re welcome

Viewing 14 posts - 1 through 14 (of 14 total)
  • You must be logged in to reply to this topic.