Archived topic
I need to display one word after logo
5 replies · Started by Anoop Kumar Vaishya on December 30, 2022
generate_before_logo or generate_after_logo none of them working.
What could be issue?
Hi there,
do you have a Logo Image set on your site ?
It is presently set using two methods at the same time
// Inline Logo for Desktop
add_filter( 'generate_logo_output', function( $output ) {
printf(
'<div class="navigation-branding site-logo">
<a href="%1$s" title="%2$s" rel="home">
<svg ...... </svg>
</a>
</div>',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
);
} );
// Logo for Mobile Header loaded via wp-content File URL.
Customizing ▸ Layout > Header
What I am expecting.
- Ideally, I would like to set logo inlined for Desktop and Mobile Header both. Note: I don't use sticky but for some reason I have like this.
- Using Elements > Hooks > If I am using generate_after_logo then nothing appears. Ref: https://i.imgur.com/XqDIiXy.png I have checked source code before writing this.
Please provide solution for both things.
Thanks
Lets focus on the desktop first.
As you're using the generate_logo_output filter then you can include you extra HTML in there eg.
add_filter( 'generate_logo_output', function( $output ) {
printf(
'<div class="navigation-branding site-logo">
<a href="%1$s" title="%2$s" rel="home">
<svg ...... </svg>
</a>
<p>Your extra text here</p>
</div>',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
);
} );
Hello!
Thank you for understanding my question.
The provided solution works as expected.
Kindly provide snippet for mobile header logo as well.
Thanks
For mobile header logo you can use the generate_mobile_header_logo_output filter. Doc with some examples here:
https://docs.generatepress.com/article/generate_mobile_header_logo_output/
Repurposing the first example:
add_filter( 'generate_mobile_header_logo_output', function( $output ) {
if ( ! function_exists( 'generate_menu_plus_get_defaults' ) ) {
return $output;
}
$settings = wp_parse_args(
get_option( 'generate_menu_plus_settings', array() ),
generate_menu_plus_get_defaults()
);
return sprintf(
'<div class="site-logo mobile-header-logo">
<a href="%1$s" title="%2$s" rel="home">
<img src="%3$s" alt="%4$s" />
</a>
<p>Your extra text here</p>
</div>',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
esc_url( apply_filters( 'generate_mobile_header_logo', $settings['mobile_header_logo'] ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
);
} );
