• Resolved terryrook

    (@terryrook)


    The Twenty Fifteen template does this cool thing to help with SEO that when you make the home page display your posts it changes the header so the Site Title gets a H1 tag and the Site Description and page title get a H2 tag. This only happens on the home page.

    Now I want to be able to do this when the home page is set to display a static page, but just for the home page. How can I assign the same header the post uses to just the home page?

    Thanks loads for any help

Viewing 1 replies (of 1 total)
  • Thread Starter terryrook

    (@terryrook)

    OK I’ve found a solution so just I thought it might be good to share.

    In a child theme of Twenty Fifteen copy and change the header.php file and the content-page.php file.

    header.php file – Change this code:

    <?php
    					if ( is_front_page() && is_home() ) : ?>

    To this code:

    <?php
    					if ( is_front_page() ) : ?>

    That gives the site-title a h1 tag only on the home page

    content-page.php – Change this code:

    <header class="entry-header">
    		<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
    	</header><!-- .entry-header -->

    To this code:

    <!-- Page title H1 on home H2 elsewhere-->
    		<?php
    			if ( is_front_page() ) : ?>
    				<header class="entry-header">
    					<?php the_title( '<h2 class="entry-title">', '</h2>' ); ?>
    				</header><!-- .entry-header -->
    		<?php else : ?>
    				<header class="entry-header">
    					<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
    				</header><!-- .entry-header -->
    		<?php endif; ?>
    <!-- End Page title H1 on home H2 elsewhere-->

    That gives the page titles a h2 tag on the home page and a h1 tag elsewhere.

Viewing 1 replies (of 1 total)
  • The topic ‘Twenty Fifteen – How to change header on just the home page when its static’ is closed to new replies.