H1 in home page and other pages
-
The theme has the <h1> tag in the menu, not in the title of the blog. So for the homepage, I put the <h1> on the title of the blog, and in the call to the menu I replaced with the <h2> tag, in this way:
<h1><a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"> <img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="crossroad" /> </a></h1>
and
<h2 class="assistive-text"><?php _e( 'Menu', 'leaf' ); ?></h2>
Now the home page is 100% SEO.
The problem is that all the other pages (single, archives, etc) show two <h1>, blog’s title and post’s title, and that’s no good.
I’d wish there was only one <h1>, for the post’s title, removing the one on the title of the blog, for all pages except the home page.
Maybe it would be possible with a basic code like this in the header:<?php if(is_home() || is_front_page()) {?> <h1><?php bloginfo('name');?></h1> <?php } else { ?> <?php bloginfo('name');?> <?php } ?>
But I don’t know how to replace or add to the original, which is this:
<?php $header_image = get_header_image(); if ( ! empty( $header_image ) ) { ?> <a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"> <img src="<?php header_image(); ?>" width="<?php echo get_custom_header()->width; ?>" height="<?php echo get_custom_header()->height; ?>" alt="" /> </a> <?php } else { ?>
Can you help me please?
- The topic ‘H1 in home page and other pages’ is closed to new replies.