Archived topic
Change Header and Sticky logo image on one page
5 replies · Started by webyogi on January 14, 2023
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.
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
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' ) ) )
);
} );
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' ) ) )
);
} );
Thanks David and Ying.
You are welcome :)