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

  1. obiwan77
    Posted 5 years ago #

    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.

  2. Michael
    Forum Moderator
    Posted 5 years ago #

    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">
    						<a href="<?php echo home_url( '/' ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a>
    				</<?php echo $heading_tag; ?>>

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

Topic Closed

This topic has been closed to new replies.

About this Topic