[Resolved] Adding custom SVG Mobile logo

Home Forums Support [Resolved] Adding custom SVG Mobile logo

Home Forums Support Adding custom SVG Mobile logo

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1685772
    Matic

    Hi,
    a while ago, I created a SVG path logo using code I found in a support thread on this forum. This is the code I added to my child theme’s Functions.php:

    add_filter( 'generate_logo_output', function() {
    return sprintf( // WPCS: XSS ok, sanitization ok.
    '<div class="site-logo">
      <a href="%1$s" title="%2$s" rel="home">
        <svg>MY_SVG
        </svg>
      </a>
    </div>',
    esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
    esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
    );
    } );
    

    Now, I want to do the same with my Mobile logo, but I cannot figure it out. This is the code I’m using:

    add_filter( 'generate_mobile_header_logo_output', function() {
    return sprintf( // WPCS: XSS ok, sanitization ok.
    '<div class="site-logo mobile-header-logo">
      <a href="%1$s" title="%2$s" rel="home">
        <svg>MY_MOBILE_SVG
        </svg>
      </a>
    </div>',
    esc_url( apply_filters( 'generate_mobile_header_logo', $settings['mobile_header_logo'] ) ),
    esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
    );
    } );
    

    Any ideas?

    Cheers,
    Matic

    #1685970
    Elvin
    Staff
    Customer Support

    Hi there,

    generate_mobile_header_logo_output is used if you have mobile header enabled.

    But yes, if you have that enabled, you should use that filter as well.

    Example:

    add_filter( 'generate_mobile_header_logo_output', function( $output ) {
        return sprintf(
            '<div class="site-logo mobile-header-logo">
                <a href="%1$s" title="%2$s" rel="home">
                    [YOUR INLINE SVG HERE]
                </a>
            </div>',
            esc_url( apply_filters( 'generate_logo_href', home_url( '/' ) ) ),
            esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
        );
    } );
    #1686574
    Matic

    Hi Elvin,

    I did try that.

    In addition, I disabled my CDN, my caching, removed custom CSS, and copied your code.
    Unfortunately, the mobile logo still does not show.

    Cheers,
    Matic

    #1686833
    David
    Staff
    Customer Support

    Hi there

    can you share a link to the site where we can ‘see’ the missing logo.

    #1686840
    Matic

    Here, for example: https://www.photutorial.com/

    #1687304
    David
    Staff
    Customer Support

    Do you have a logo set in the Customizer > Layout > Header for the Mobile logo? If not, can you add one.

    #1688661
    Matic

    Hey David,

    this actually fixed the problem. I just assigned a random image as logo, and my SVG path logo popped-in. 😮

    Thank you for you help.

    Cheers,
    Matic

    #1688726
    David
    Staff
    Customer Support

    Glad to be of help

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