WordPress.org

Make WordPress Core


Ignore:
Timestamp:
01/09/2016 07:32:42 AM (5 years ago)
Author:
dd32
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/canonical.php

    r36010 r36237  
    173173            if ( $redirect_url = get_permalink(get_query_var('page_id')) )
    174174                $redirect['query'] = remove_query_arg('page_id', $redirect['query']);
    175         } 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 ) {
     175        } elseif ( is_page() && !is_feed() && 'page' == get_option('show_on_front') && get_queried_object_id() == get_option('page_on_front')  && ! $redirect_url ) {
    176176            $redirect_url = home_url('/');
    177177        } 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 ) {
     
    263263
    264264        // Post Paging
    265         if ( is_singular() && ! is_front_page() && get_query_var('page') ) {
     265        if ( is_singular() && get_query_var('page') ) {
    266266            if ( !$redirect_url )
    267267                $redirect_url = get_permalink( get_queried_object_id() );
    268             $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
     268
     269            $page = get_query_var( 'page' );
     270            if ( $page > 1 ) {
     271                if ( is_front_page() ) {
     272                    $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( "$wp_rewrite->pagination_base/$page", 'paged' );
     273                } else {
     274                    $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( $page, 'single_paged' );
     275                }
     276            }
    269277            $redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
    270278        }
Note: See TracChangeset for help on using the changeset viewer.