Use H1 for title image on homepage, but H2 everywhere else
-
I’m trying to have it (mainly for SEO) that on my homepage my title image is enclosed in <h1>, while on all other pages it is <h2> – the post title will be <h1> in this case.
I tried to do it with php, but having absolutely no php knowledge, my attempt broke my page, giving a php error.
<div id="logo"> <?php if (is_home()) { <h1><a href="<?php echo get_option( 'home' ); ?>"><img src="<?php header_image() ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" /></a></h1>; } else { <h2><a href="<?php echo get_option( 'home' ); ?>"><img src="<?php header_image() ?>" alt="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" /></a></h2>; } ?> <div id="desc"><?php bloginfo( 'description' ); ?></div> </div><!-- /logo -->
Anyone know why it’s not working, or an alternative way I could achieve this?
Cheers.
Viewing 10 replies - 1 through 10 (of 10 total)
Viewing 10 replies - 1 through 10 (of 10 total)
- The topic ‘Use H1 for title image on homepage, but H2 everywhere else’ is closed to new replies.