Archived topic
Alt text for Logo.
3 replies · Started by Zee on July 16, 2022
Hi there -
I'm having issues trying to modify the alt text for my website's logo. I've tried all the filters suggested here, adding them into Snippets: https://generatepress.com/forums/topic/site-logo-alt-tag-filter/ but the logo's alt text still just shows the site title.
Any help would be much appreciated!
Hi there,
this is the correct filter:
https://docs.generatepress.com/article/generate_logo_title/
If you have page caching - try clearing that after adding it.
If still an issue it may be because you have a plugin that is switching the images to webP and that may be interfering.
Hi David,
generate_logo_title changes both the title and alt attributes.
We are hoping to make the title and the alt text to be a different.
Thanks
Hi Kale,
You can try generate_logo_output filter, you can replace the my alt text and my logo title:
add_filter( 'generate_logo_output','tu_logo_atts', 10, 2 );
function tu_logo_atts( $output, $logo ) {
printf(
'<div class="site-logo">
<a href="%1$s" title="my logo title" rel="home" alt="my alt text">
<img class="header-image" src="%2$s" alt="my alt text" title="my logo title" />
</a>
</div>',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_url( apply_filters( 'generate_logo', $logo ) )
);
}