Site logo

[Resolved] Change Header and Sticky logo image on one page

Home Forums Support [Resolved] Change Header and Sticky logo image on one page

Home Forums Support Change Header and Sticky logo image on one page

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2495911
    webyogi

    Hi,

    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.

    #2496395
    David
    Staff
    Customer Support

    Hi there,

    it requires a PHP Snippet to do that, here for example:

    add_filter( 'generate_sticky_navigation_logo_output', function($logo) {
        if ( ! is_user_logged_in() ) {
            return;
        }
        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' ) ) )
        );
    } );

    That will swap the logo if th user is logged in, if you want to let me know what conditions you want to show the logo i can update thee code

    #2496504
    webyogi

    Hey David,

    So if I want to change the sticky image for a specific page, then I guess code will be:

    
    add_filter( 'generate_sticky_navigation_logo_output', function($logo) {
        if ( ! is_page( 447 ) ) {
            return;
        }
        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' ) ) )
        );
    } );
    
    #2496606
    Ying
    Staff
    Customer Support

    Hi there,

    The code would be:

    add_filter( 'generate_sticky_navigation_logo_output', function($logo) {
        if ( ! is_page( 447 ) ) {
            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' ) ) )
        );
    } );
    #2497821
    webyogi

    Thanks David and Ying.

    #2497889
    Ying
    Staff
    Customer Support

    You are welcome   🙂

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