• A student of mine asked me this question and I am stuck with half an answer.

    So far this works:

    1. Duplicate singular.php (a default page template) and rename it front-page.php in your child theme. WP always loads front-page.php if it finds one. It has precedence.

    2. Duplicate header.php and call it header-home.php

    3. Insert this code to call up the title wherever you like:
    <?php echo the_title( ‘<h1 class=”entry-title”>’, ‘</h1>’ ); ?>

    4. In front-page.php edit the get_header(); to get_header(‘home’);

    However, I wind up with 2 H1 tags on the home page. I cannot find which file(s) to edit in order to the remove the default H1, nor how to set it up so that it works only on the home page.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hey:
    Why not use CSS? A CSS solution might be something like:

    #post-882 > div.cover-header.bg-image.bg-attachment-fixed > div > div > header > div > h1 {
    position:absolute;
    top: 80px;
    left: 40px;
    }

    The post # will change for you and if you are using a different template.

    Phil

    Thread Starter jacgfxgeek

    (@jacgfxgeek)

    That’s obviously a perfect way to do it. However, now (as a teacher) I still want to understand how 2020 works. It’s not exactly intuitive for me.

    Hey:

    The H1 is rendered via entry-header.php I am using cover template and the H1 is rendered as follows:

    <header class="entry-header has-text-align-center">
      <div class="entry-header-inner section-inner medium">
        <h1 class="entry-title">Ann Arbor Computer Society</h1>
        ...
      </div><!-- .entry-header-inner -->
    </header><!-- .entry-header -->

    The header tag has the has-text-align-center class. It seems to me that you would want to remove that for your special case. I would use the:
    is_front_page()
    function to render different header tags.

    Phil

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘2020 Child: Moving H1 on Home Only, which file(s) to edit’ is closed to new replies.