diff --git a/src/wp-includes/class-wp-query.php b/src/wp-includes/class-wp-query.php index f95cb6149fc43..9ed83cb9b6f6b 100644 --- a/src/wp-includes/class-wp-query.php +++ b/src/wp-includes/class-wp-query.php @@ -4374,16 +4374,29 @@ public function is_comment_feed() { * @return bool Whether the query is for the front page of the site. */ public function is_front_page() { - // Most likely case. - if ( 'posts' === get_option( 'show_on_front' ) && $this->is_home() ) { - return true; - } elseif ( 'page' === get_option( 'show_on_front' ) && get_option( 'page_on_front' ) - && $this->is_page( get_option( 'page_on_front' ) ) - ) { + $show_on_front = get_option( 'show_on_front' ); + + // If Your Latest Posts is selected. + if ( 'posts' === $show_on_front && $this->is_home() ) { return true; - } else { - return false; } + + if ( 'page' === $show_on_front ) { + $page_on_front = get_option( 'page_on_front' ); + $page_for_posts = get_option( 'page_for_posts' ); + + // If a static homepage is set and we're on that page. + if ( $page_on_front && $this->is_page( $page_on_front ) ) { + return true; + } + + // Edge case where a posts page has been selected but a homepage is not set. + if ( $page_for_posts && is_home() && ( get_queried_object_id() !== (int) $page_for_posts ) ) { + return true; + } + } + + return false; } /**