Archived topic
Add a css class to site-title
3 replies · Started by Adnan on November 29, 2021
Viewing posts 1–4 of 4
How can I add the "notranslate" class only to the site-title in the header?
Hi Adnan,
Try this PHP snippet:
add_filter( 'generate_site_title_output', function( $output ) {
return sprintf(
'<%1$s class="main-title notranslate" itemprop="headline">
%3$s
</%1$s>',
( is_front_page() && is_home() ) ? 'h1' : 'p',
esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
get_bloginfo( 'name' )
);
});
Adding PHP: https://docs.generatepress.com/article/adding-php/
Let me know if you need further assistance :)
Hi Ying,
thank you. Works perfect. I have added the Link too (code below). Thank you and kind regards. Adnan
add_filter( 'generate_site_title_output', function( $output ) {
return sprintf(
'<%1$s class="main-title notranslate" itemprop="headline">
<a href="%2$s">%3$s</a>
</%1$s>',
( is_front_page() && is_home() ) ? 'h1' : 'p',
esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
get_bloginfo( 'name' )
);
});
You are welcome :)
This archived topic is closed to new replies.