Site logo

Archived topic

Site title is showing as , how to change it to H1?

8 replies · Started by Rekamedia on October 14, 2022

Viewing posts 1–9 of 9

Hi,

Why my website site title is showing the site title in <p> tag?
Normally site title will shown as H1. This is currently is shown in my website:

<p class="main-title" itemprop="headline"><a href="https://google.com/" rel="home">Site Title</a></p>

Hi there,

by default the Theme outputs the site title as follows:

1. Homepage set to Display latests posts only uses: <h1>.
As this page does not have a H1 Content title by default.

2. All other pages it displays the site title as a <p>
As other pages by default have a H1 Content title

So do you want every page to have the site title as a H1 ? As that may lead to multiple H1s on pages and posts.

Hi,

Let me try create a heading in the page with H1 tag.

(Update): I created a heading H1 with the main keyword. So now the site title is still showing in <p>, and the homepage has one H1 with the main keyword. Is this normal?

Usually on other theme, the site title is always in H1.

As i said above the only time we output the Site Title as a H1 is on a Homepage that is set to display the latest posts.
As this is the only page that does not have a H1 Content Title.

On every other Page, Post, Archive the Content Title gets output as a H1, so you do not want the Site Title to be a H1 there.

But, my homepage is not showing latest post, this is my use case, it's a sales page. How to change this?
I want the site title to be always in H1, so I can use other heading to other keywords.

Any code that I can use to fix this?

You can add this PHP Snippet and it will change the Site Title to H1 on every page:


add_filter( 'generate_site_title_output', function( $output ) {
    return sprintf(
        '<h1 class="main-title"%3$s>
            <a href="%2$s" rel="home">
                %2$s
            </a>
        </h1>',
        esc_url( apply_filters( 'generate_site_title_href', home_url( '/' ) ) ),
        get_bloginfo( 'name' ),
        'microdata' === generate_get_schema_type() ? ' itemprop="headline"' : ''
    );
});

It says synxtax error?

Update: It's ok, missing a ;

Sorry about that, correct the code above.

Glad to hear you got it working

This archived topic is closed to new replies.