[wp-trac] [WordPress Trac] #30305: Twenty Fifteen: Simplify Code for h1 on Blog Index Page when Front Page is in Use

WordPress Trac noreply at wordpress.org
Mon Nov 10 15:32:26 UTC 2014


#30305: Twenty Fifteen: Simplify Code for h1 on Blog Index Page when Front Page is
in Use
---------------------------+-----------------------------
 Reporter:  davidakennedy  |      Owner:
     Type:  enhancement    |     Status:  new
 Priority:  normal         |  Milestone:  Awaiting Review
Component:  Bundled Theme  |    Version:  trunk
 Severity:  normal         |   Keywords:
  Focuses:                 |
---------------------------+-----------------------------
 In Twenty Fifteen, there is a chunk of code that creates a h1 for the blog
 index page when a page is in use for the front page. This is the main h1
 of the page, and hidden visually as it mainly serves screen reader users.
 This code is:


 {{{
 <?php if ( is_home() && ! is_front_page() ) : ?>
         <header>
                 <h1 class="page-title screen-reader-text"><?php echo
 esc_html( get_the_title( get_option( 'page_for_posts' ) ) ); ?></h1>
         </header>
 <?php endif; ?>
 }}}

 In thinking about this, I realized my original code could be much simpler:

 {{{
 <?php if ( is_home() && ! is_front_page() ) : ?>
         <header>
                 <h1 class="page-title screen-reader-text"><?php
 single_post_title(); ?></h1>
         </header>
 <?php endif; ?>
 }}}

 That template tag is great to use here because it's outside the loop and
 simplifies the code.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30305>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list