From b4aa9d18b1268faebc95df19f995231476218ae1 Mon Sep 17 00:00:00 2001 From: Tammie Lister Date: Mon, 27 May 2024 12:28:18 +0000 Subject: [PATCH] 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 --- wp-content/themes/twentyseventeen/functions.php | 13 +++++++++++++ wp-content/themes/twentyseventeen/header.php | 7 +------ wp-includes/version.php | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/wp-content/themes/twentyseventeen/functions.php b/wp-content/themes/twentyseventeen/functions.php index b4b03ed6c7..fcc9f78ebd 100644 --- a/wp-content/themes/twentyseventeen/functions.php +++ b/wp-content/themes/twentyseventeen/functions.php @@ -689,6 +689,19 @@ if ( ! function_exists( 'wp_get_list_item_separator' ) ) : } 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. */ diff --git a/wp-content/themes/twentyseventeen/header.php b/wp-content/themes/twentyseventeen/header.php index 2fd53739a6..9ff5c9d415 100644 --- a/wp-content/themes/twentyseventeen/header.php +++ b/wp-content/themes/twentyseventeen/header.php @@ -47,12 +47,7 @@ '; echo get_the_post_thumbnail( get_queried_object_id(), 'twentyseventeen-featured-image' ); echo ''; diff --git a/wp-includes/version.php b/wp-includes/version.php index 4b77420c46..3f0ade7568 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @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.