Canonical: Generate the correct canonical url for paged posts/pages when they're used as the page_on_front.
This fixes an issue where pages become inacessible on a front page post. Fixes #35344 for trunk. Built from https://develop.svn.wordpress.org/trunk@36237 git-svn-id: http://core.svn.wordpress.org/trunk@36204 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d57776b108
commit
84a3b4407f
|
@ -172,7 +172,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
||||||
} elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) {
|
} elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) {
|
||||||
if ( $redirect_url = get_permalink(get_query_var('page_id')) )
|
if ( $redirect_url = get_permalink(get_query_var('page_id')) )
|
||||||
$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
|
$redirect['query'] = remove_query_arg('page_id', $redirect['query']);
|
||||||
} elseif ( is_page() && !is_feed() && isset($wp_query->queried_object) && 'page' == get_option('show_on_front') && $wp_query->queried_object->ID == get_option('page_on_front') && ! $redirect_url ) {
|
} elseif ( is_page() && !is_feed() && 'page' == get_option('show_on_front') && get_queried_object_id() == get_option('page_on_front') && ! $redirect_url ) {
|
||||||
$redirect_url = home_url('/');
|
$redirect_url = home_url('/');
|
||||||
} elseif ( is_home() && !empty($_GET['page_id']) && 'page' == get_option('show_on_front') && get_query_var('page_id') == get_option('page_for_posts') && ! $redirect_url ) {
|
} elseif ( is_home() && !empty($_GET['page_id']) && 'page' == get_option('show_on_front') && get_query_var('page_id') == get_option('page_for_posts') && ! $redirect_url ) {
|
||||||
if ( $redirect_url = get_permalink(get_option('page_for_posts')) )
|
if ( $redirect_url = get_permalink(get_option('page_for_posts')) )
|
||||||
|
@ -262,10 +262,18 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Post Paging
|
// Post Paging
|
||||||
if ( is_singular() && ! is_front_page() && get_query_var('page') ) {
|
if ( is_singular() && get_query_var('page') ) {
|
||||||
if ( !$redirect_url )
|
if ( !$redirect_url )
|
||||||
$redirect_url = get_permalink( get_queried_object_id() );
|
$redirect_url = get_permalink( get_queried_object_id() );
|
||||||
$redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
|
|
||||||
|
$page = get_query_var( 'page' );
|
||||||
|
if ( $page > 1 ) {
|
||||||
|
if ( is_front_page() ) {
|
||||||
|
$redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( "$wp_rewrite->pagination_base/$page", 'paged' );
|
||||||
|
} else {
|
||||||
|
$redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( $page, 'single_paged' );
|
||||||
|
}
|
||||||
|
}
|
||||||
$redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
|
$redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '4.5-alpha-36236';
|
$wp_version = '4.5-alpha-36237';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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