Make WordPress Core

Ticket #11694: canonical-pagination.patch

File canonical-pagination.patch, 1021 bytes (added by joostdevalk, 11 years ago)

Canonical - Pagination Patch

  • wp-includes/canonical.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    214214                if ( is_singular() && ! is_front_page() && get_query_var('page') ) {
    215215                        if ( !$redirect_url )
    216216                                $redirect_url = get_permalink( get_queried_object_id() );
    217                         $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
     217
     218                        $post = get_post( get_queried_object_id() );
     219                        $pagination = wp_parse_post_content( $post );
     220                        if ( get_query_var( 'page' ) <= $pagination['numpages'] ) {
     221                                $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
     222                        } else {
     223                                $redirect_url = trailingslashit( $redirect_url );
     224                        }
    218225                        $redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
    219226                }
    220227