Twenty Seventeen: Hardens the logic for calling featured image in `header.php`

This change uses `get_queried_object_id()` here since the `$post` global may not be set before a call to `the_post()`.

Props westonruter.

Fixes #39302.

Built from https://develop.svn.wordpress.org/trunk@39624


git-svn-id: http://core.svn.wordpress.org/trunk@39564 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
David A. Kennedy 2016-12-20 23:00:43 +00:00
parent 7d70dabf59
commit 4177e37593
2 changed files with 8 additions and 4 deletions

View File

@ -41,10 +41,14 @@
</header><!-- #masthead -->
<?php
// If a regular post or page, and not the front page, show the featured image.
if ( has_post_thumbnail() && ( is_single() || ( is_page() && ! twentyseventeen_is_frontpage() ) ) ) :
/*
* If a regular post or page, and not the front page, show the featured image.
* Using get_queried_object_id() here since the $post global may not be set before a call to the_post().
*/
if ( ( is_single() || ( is_page() && ! twentyseventeen_is_frontpage() ) ) && has_post_thumbnail( get_queried_object_id() ) ) :
echo '<div class="single-featured-image-header">';
the_post_thumbnail( 'twentyseventeen-featured-image' );
echo get_the_post_thumbnail( get_queried_object_id(), 'twentyseventeen-featured-image' );
echo '</div><!-- .single-featured-image-header -->';
endif;
?>

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-alpha-39623';
$wp_version = '4.8-alpha-39624';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.