mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-09 22:29:05 +02:00
Twenty Seventeen: Add filter for display of featured image in header.
When a layout doesn't use custom post types it was appearing broken. This adds a filter for the display of the featured image to resolve this. Props justnorris, JPry, davidakennedy, SergeyBiryukov, zkarj, poena, nhrrob, lamarajan. Fixes #39281. Built from https://develop.svn.wordpress.org/trunk@58206 git-svn-id: http://core.svn.wordpress.org/trunk@57669 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
31b37a5eb3
commit
b4aa9d18b1
@ -689,6 +689,19 @@ if ( ! function_exists( 'wp_get_list_item_separator' ) ) :
|
|||||||
}
|
}
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a regular post or page, and not the front page, show the featured image below the header.
|
||||||
|
* Using get_queried_object_id() here since the $post global may not be set before a call to the_post().
|
||||||
|
*
|
||||||
|
* @since Twenty Seventeen 3.7
|
||||||
|
*
|
||||||
|
* @return bool Whether the post thumbnail should be shown.
|
||||||
|
*/
|
||||||
|
function twentyseventeen_should_show_featured_image() {
|
||||||
|
$show_featured_image = ( is_single() || ( is_page() && ! twentyseventeen_is_frontpage() ) ) && has_post_thumbnail( get_queried_object_id() );
|
||||||
|
return apply_filters( 'twentyseventeen_should_show_featured_image', $show_featured_image );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement the Custom Header feature.
|
* Implement the Custom Header feature.
|
||||||
*/
|
*/
|
||||||
|
@ -47,12 +47,7 @@
|
|||||||
</header><!-- #masthead -->
|
</header><!-- #masthead -->
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
if ( twentyseventeen_should_show_featured_image() ) :
|
||||||
/*
|
|
||||||
* 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">';
|
echo '<div class="single-featured-image-header">';
|
||||||
echo get_the_post_thumbnail( get_queried_object_id(), 'twentyseventeen-featured-image' );
|
echo get_the_post_thumbnail( get_queried_object_id(), 'twentyseventeen-featured-image' );
|
||||||
echo '</div><!-- .single-featured-image-header -->';
|
echo '</div><!-- .single-featured-image-header -->';
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.6-alpha-58205';
|
$wp_version = '6.6-alpha-58206';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user