[Resolved] Site title is p element on front page instead of h1

Home Forums Support [Resolved] Site title is p element on front page instead of h1

Home Forums Support Site title is p element on front page instead of h1

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #996873
    Ben

    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

    #997340
    Tom
    Lead Developer
    Lead Developer

    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 ๐Ÿ™‚

    #997641
    Ben

    Hi Tom,

    I appreciate your help!

    Regards,

    Ben

    #997951
    Tom
    Lead Developer
    Lead Developer

    No problem! ๐Ÿ™‚

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.