WordPress.org

Make WordPress Core

Ticket #28081: 1.diff

File 1.diff, 743 bytes (added by sagarkbhatt, 2 years ago)

Add fix for duplicate content issue and fix unwanted pagination

  • src/wp-includes/canonical.php

    diff --git a/src/wp-includes/canonical.php b/src/wp-includes/canonical.php
    index ad219c271..69344046b 100644
    a b function redirect_canonical( $requested_url = null, $do_redirect = true ) { 
    281281                                $redirect_url = get_permalink( get_queried_object_id() );
    282282                        }
    283283
    284                         $page = get_query_var( 'page' );
     284                        if ( $wp_query->post && false === strpos( $wp_query->post->post_content, '<!--nextpage-->' ) ) {
     285                                $page = 1;
     286                        } else {
     287                                $page = get_query_var( 'page' );
     288                        }
     289
    285290                        if ( $page > 1 ) {
    286291                                if ( is_front_page() ) {
    287292                                        $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( "$wp_rewrite->pagination_base/$page", 'paged' );