WordPress.org

Make WordPress Core

Ticket #12456: 12456.diff

File 12456.diff, 933 bytes (added by dd32, 8 years ago)
  • wp-includes/canonical.php

     
    6161        $redirect_url = false;
    6262
    6363        // Notice fixing
    64         if ( !isset($redirect['path']) )  $redirect['path'] = '';
    65         if ( !isset($redirect['query']) ) $redirect['query'] = '';
     64        if ( !isset($redirect['path']) )
     65                $redirect['path'] = '';
     66        if ( !isset($redirect['query']) )
     67                $redirect['query'] = '';
    6668
    6769        if ( is_singular() && 1 > $wp_query->post_count && ($id = get_query_var('p')) ) {
    6870
     
    164166                                }
    165167
    166168                        }
     169                } elseif ( is_singular() ) {
     170                        $post_url = get_permalink( $wp_query->get_queried_object_id() );
     171                        if ( strpos($requested_url, $post_url) === false ) // If the full post's URL is not within the requested url, lets redirect there.
     172                                $redirect_url = $post_url;
    167173                }
    168174
    169175                // paging and feeds