Archived topic
Remove title attribute from logo
10 replies · Started by Dan on September 5, 2018
Hello,
How can I filter out the title attribute from the logo?
I don't want the small tooltip to show up once hovering over the image.
The action hook is this (inside inc/structure/header.php)
$attr = apply_filters( 'generate_logo_attributes', array(
'class' => 'header-image',
'alt' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
'src' => $logo_url,
'title' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
) );
Thanks,
Dan
Hi Dan,
Give this filter a shot:
https://docs.generatepress.com/article/generate_logo_output/
Let me know if this helps :)
Thanks Leo,
I modified the filter a bit to this (to remove the title attribute):
add_filter( 'generate_logo_output', 'tu_no_logo_title', 10, 3 );
function tu_no_logo_title( $output, $logo_url, $html_attr ) {
printf(
'<div class="site-logo">
<a href="%1$s" rel="home">
<img %3$s />
</a>
</div>',
$html_attr
);
}
but it removed the logo altogether.
Still, I don't see where it removes the 'title' from the img tag.
Dan
What if you simply remove the site title from Site Identity in the customizer?
This solution should also work:
https://generatepress.com/forums/topic/hide-tooltip-when-hover-on-header-image/#post-417144
Thanks Leo,
The last solution did the trick as I didn't want to remove the title completely from the site.
Dan
No problem :)
I'm also trying to remove or change the title attribute text from the img tag in the site logo. The issue is that the alt-text and the title are the same, which generates an accessibility error.
When I use the second fix,
add_filter( 'generate_logo_title', 'lh_remove_logo_alt' );
function lh_remove_logo_alt() {
return '';
}
or anything with the 'generate_logo_title' filter it removes both the alt-text and the title attribute, which creates the more serious "no alt-text" error.
Is there a way to remove the title text without affecting the alt-text?
Hi there,
Try this:
add_filter( 'generate_logo_attributes', function( $atts ) {
unset( $atts['title'] );
return $atts;
} );
That did the trick perfectly! Thank you so much!
Is there a similar snippet/filter for the navigation search? The title on the <li> tag is the same as the screen reader text inside.
Thanks again!
Can you open a new topic for the separate question?
Thanks!