Make WordPress Core

Opened 9 years ago

Closed 9 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's profile davidakennedy Owned by: iandstewart's profile 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)

30305.patch (576 bytes) - added by davidakennedy 9 years ago.
Simplify code for visually hidden h1 on blog index page.

Download all attachments as: .zip

Change History (5)

@davidakennedy
9 years ago

Simplify code for visually hidden h1 on blog index page.

#1 @davidakennedy
9 years ago

  • Keywords has-patch needs-testing added

This ticket was mentioned in Slack in #core-themes by iandstewart. View the logs.


9 years ago

#3 @iandstewart
9 years ago

  • Keywords commit added; needs-testing removed
  • Milestone changed from Awaiting Review to 4.1

#4 @iandstewart
9 years ago

  • Owner set to iandstewart
  • Resolution set to fixed
  • Status changed from new to closed

In 30304:

Twenty Fifteen: simplify the code used to generate screen reader text for the is_home title.

Props davidakennedy, fixes #30305

Note: See TracTickets for help on using tickets.