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. git-svn-id: https://develop.svn.wordpress.org/trunk@36237 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
5f55910b5c
commit
3cce67f8bc
@ -172,7 +172,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
||||
} elseif ( is_page() && !empty($_GET['page_id']) && ! $redirect_url ) {
|
||||
if ( $redirect_url = get_permalink(get_query_var('page_id')) )
|
||||
$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('/');
|
||||
} 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')) )
|
||||
@ -262,10 +262,18 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) {
|
||||
}
|
||||
|
||||
// Post Paging
|
||||
if ( is_singular() && ! is_front_page() && get_query_var('page') ) {
|
||||
if ( is_singular() && get_query_var('page') ) {
|
||||
if ( !$redirect_url )
|
||||
$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'] );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user