diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php index b97db55709..12f7e5e467 100644 --- a/wp-includes/canonical.php +++ b/wp-includes/canonical.php @@ -186,6 +186,22 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { ); } + // Strip off non-existing links from single posts or pages. + if ( get_query_var( 'page' ) ) { + $post_id = 0; + + if ( $wp_query->queried_object instanceof WP_Post ) { + $post_id = $wp_query->queried_object->ID; + } elseif ( $wp_query->post ) { + $post_id = $wp_query->post->ID; + } + + $redirect_url = get_permalink( $post_id ); + + $redirect['path'] = rtrim( $redirect['path'], (int) get_query_var( 'page' ) . '/' ); + $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); + } + if ( ! $redirect_url ) { $redirect_url = redirect_guess_404_permalink(); @@ -197,14 +213,6 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { ); } } - - // Strip off non-existing page links from single posts or pages. - if ( get_query_var( 'page' ) && $wp_query->post ) { - $redirect['path'] = rtrim( $redirect['path'], (int) get_query_var( 'page' ) . '/' ); - $redirect['query'] = remove_query_arg( 'page', $redirect['query'] ); - - $redirect_url = get_permalink( $wp_query->post->ID ); - } } elseif ( is_object( $wp_rewrite ) && $wp_rewrite->using_permalinks() ) { // Rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101. diff --git a/wp-includes/class-wp.php b/wp-includes/class-wp.php index 980777bb67..ba1f15d033 100644 --- a/wp-includes/class-wp.php +++ b/wp-includes/class-wp.php @@ -670,15 +670,15 @@ class WP { } elseif ( $wp_query->posts ) { $content_found = true; - $post = isset( $wp_query->post ) ? $wp_query->post : null; - - // Only set X-Pingback for single posts that allow pings. - if ( is_singular() && $post && pings_open( $post ) && ! headers_sent() ) { - header( 'X-Pingback: ' . get_bloginfo( 'pingback_url', 'display' ) ); - } - - // Check for paged content that exceeds the max number of pages. if ( is_singular() ) { + $post = isset( $wp_query->post ) ? $wp_query->post : null; + + // Only set X-Pingback for single posts that allow pings. + if ( $post && pings_open( $post ) && ! headers_sent() ) { + header( 'X-Pingback: ' . get_bloginfo( 'pingback_url', 'display' ) ); + } + + // Check for paged content that exceeds the max number of pages. $next = ''; if ( $post && ! empty( $this->query_vars['page'] ) ) { // Check if content is actually intended to be paged. @@ -691,6 +691,11 @@ class WP { } } + // The posts page does not support the pagination. + if ( $wp_query->is_posts_page && ! empty( $this->query_vars['page'] ) ) { + $content_found = false; + } + if ( $content_found ) { $set_404 = false; } diff --git a/wp-includes/version.php b/wp-includes/version.php index 8bc17e3e57..661db90b0b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.5-alpha-47759'; +$wp_version = '5.5-alpha-47760'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.