[Support request] HTML tag of main title

Home Forums Support HTML tag of main title

  • This topic has 1 reply, 2 voices, and was last updated 4 years ago by Tom.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #274529

    Hi Tom,

    on my website I want to use the H1 tag for the main title when the front page is shown, and the P tag when another page is shown. For SEO reasons.

    I created a child theme to accomplish the same, but then came across the following code, from which I see your theme already has this feature built in:

    file: /inc/template_tags.php

    <?php if ( false == $disable_title ) : ?>
    <?php if ( is_front_page() && is_home() ) : ?>
    <h1 class=”main-title” itemprop=”headline”>” rel=”home”><?php bloginfo( ‘name’ ); ?></h1>
    <?php else : ?>
    <p class=”main-title” itemprop=”headline”>” rel=”home”><?php bloginfo( ‘name’ ); ?></p>
    <?php endif; ?>

    Strangely enough, on my website the P tag is used on the front page as well. I am using Generatepress in its normal configuration, with the site title shown in the header.
    So is_front_page() is true, but why do you check is_home()? It applies to blogs only, if I understand the documentation correctly.

    Once I remove is_home() the functionality works as desired.

    Thanks Tom


    GP Premium 1.2.94
    Lead Developer
    Lead Developer

    This is because regular pages already have an H1, your page title.

    The blog (is_home()) doesn’t have a page title, so we use the site title.

    If you’re using a static front page, then you should already have an H1, and don’t need/shouldn’t have your site title as an H1.

    Let me know if you need more info 🙂

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