Archived topic
Site title is p element on front page instead of h1
3 replies · Started by Ben on August 29, 2019
Hello,
I'm trying to make sure my site title (not the SEO title tag found in the head element, but what is found in the site identity settings in customizer) is an h1 on the front page and not a p element. In the theme files it appears that GP supports this, but it isn't working right now on the website I'm working on. I'd like to find out if maybe I haven't set the right settings or something to get it working properly.
Thanks!
Ben
Hey Ben,
The site title will only be an H1 if your home page is your posts page, as no other H1 exists on that page.
In this case, your front page is a static page, but it doesn't have an H1.
You can use a filter to tell it to be an H1 like this:
add_filter( 'generate_site_title_output', function() {
return sprintf(
'<%1$s class="main-title" itemprop="headline">
<a href="%2$s" rel="home">
%3$s
</a>
</%1$s>',
( is_front_page() ) ? 'h1' : 'p',
esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
get_bloginfo( 'name' )
);
} );
Adding PHP: https://docs.generatepress.com/article/adding-php/
Hope this helps :)
Hi Tom,
I appreciate your help!
Regards,
Ben
No problem! :)