WordPress.org

Support

Support » Themes and Templates » trying to display blog title on homepage as h1, but as h2 in posts and pages

trying to display blog title on homepage as h1, but as h2 in posts and pages

  • for SEO, I want to optimize the theme so the site’s title is used as the h1 tag ONLY on the homepage (actually =the front page if static page is displayed on the HP instead of the blog).
    On posts and pages I want the post or page title to be the h1 tag

    does anybody know how to write the php code to do this with the is_front_page() or is_home() elements?

    help would be greatly appreciated.
    cheers

Viewing 1 replies (of 1 total)
  • Michael

    @alchymyth

    Forum Moderator

    look into twenty ten (header.php) for inspiration:

    <?php $heading_tag = ( is_home() || is_front_page() ) ? 'h1' : 'div'; ?>
    				<<?php echo $heading_tag; ?> id="site-title">
    					<span>
    						<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
    					</span>
    				</<?php echo $heading_tag; ?>>

    see if you can re-write this for just ‘front_page’ and ‘h1/h2’

Viewing 1 replies (of 1 total)
  • The topic ‘trying to display blog title on homepage as h1, but as h2 in posts and pages’ is closed to new replies.
Skip to toolbar