Opened 10 years ago
Closed 10 years ago
#30305 closed enhancement (fixed)
Twenty Fifteen: Simplify Code for h1 on Blog Index Page when Front Page is in Use
Reported by: | davidakennedy | Owned by: | iandstewart |
---|---|---|---|
Milestone: | 4.1 | Priority: | normal |
Severity: | normal | Version: | 4.1 |
Component: | Bundled Theme | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
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.
Attachments (1)
Change History (5)
Note: See
TracTickets for help on using
tickets.
Simplify code for visually hidden h1 on blog index page.