Support » Themes and Templates » h1 tag issue in Twenty Eleven

  • Twenty Eleven is set to have blog title h1 and post/article titles h1 also. My problem is, on my home/front page this gives me too many h1 tags for seo purposes. Below is how I would like it to be:

    On Front page: Site Title=h1 and Article titles=h2

    On Single Post Pages: Site title=h2 and Article titles=h1

    I’m using a child theme and need to know what php code to add to make this happen.

    Thanks,
    Jeff

Viewing 3 replies - 1 through 3 (of 3 total)
  • 1. Copy header.php and content.php from the parent theme directory to your childtheme directory

    2. Open header.php (childtheme) and find

    <hgroup>
            <h1 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span></h1>
            <h2 id="site-description"><?php bloginfo( 'description' ); ?></h2>
    </hgroup>

    3. Replace with

    <hgroup>
      <?php if (is_front_page()) { ?>
            <h1 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span></h1>
            <h2 id="site-description"><?php bloginfo( 'description' ); ?></h2>
      <?php } else { ?>
            <h2 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span></h2>
            <h3 id="site-description"><?php bloginfo( 'description' ); ?></h3>
      <?php } ?>
    </hgroup>

    4. Open content.php (childtheme) and find

    <h1 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h1>


    5. replace with

    <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>

    Does that work for you?

    Thread Starter eagle8154

    (@eagle8154)

    Yes it does! Thank you kindly.

    You’re welcome!

    If you need that also on the is_home page (static frontpage = is_front_page and blog post home = is_home) just use this in your header.php

    <hgroup>
      <?php if (is_front_page() || is_home()) { ?>
            <h1 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span></h1>
            <h2 id="site-description"><?php bloginfo( 'description' ); ?></h2>
      <?php } else { ?>
            <h2 id="site-title"><span><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></span></h2>
            <h3 id="site-description"><?php bloginfo( 'description' ); ?></h3>
      <?php } ?>
    </hgroup>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘h1 tag issue in Twenty Eleven’ is closed to new replies.