• I just realized that 2012 theme puts the site title in h1 on every single page, in addition to using h1 for the individual page title.

    I like the h1 page title, but I don’t want to display the site title on every page (except the home page).

    I am using a child theme. How can I change this? I prefer it from an SEO perspective (I realize not everyone agrees, but I still see it as a pointless feature in the header and would like to change it).

    Any advice or instructions would be appreciated! Thanks in advance.

Viewing 3 replies - 1 through 3 (of 3 total)
  • One way to fix this is to use a different tag for the site title on every page except for the home page (where it would continue to use the h1 tag). The theme that I normally use does this, it uses h1 for the site title on the home page, but h3 for the site title on all other posts & pages. You can do the same thing for Twenty Twelve.

    Make a copy of the header.php file into your child theme.

    Look for this line:

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

    So right now, the h1 tag is hard coded for the site title. Change it to look like this:

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

    The is_front_page() function is used to output an h1 tag for the site title if the front page is being displayed, other wise it will output an h3 tag. Then all you need to do is add a CSS rule that styles .site-header h3 the same way as the existing rule for .site-header h1.

    Thread Starter mjmurphy53711

    (@mjmurphy53711)

    what if I wanted to remove the site title and description from displaying on any page other than the home page?

    Thanks for the above answer btw.

    Look for this code in the header.php file:

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

    and change it to this:

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

    So, you’re just adding one line after the <hgroup> tag, and another line before the </hgroup> tag. What this should do is just display the site title & site description on the front (home) page. You should make sure that you have a menu item that leads back to your home page, though, since you won’t have the site title for your visitors to click.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘h1 on every page showing site title’ is closed to new replies.