WordPress.org

Make WordPress Core

Changeset 15707


Ignore:
Timestamp:
10/04/2010 11:30:11 AM (8 years ago)
Author:
dd32
Message:

Fix canonical redirection for permalinks containing %category% with nested categories and paging. Fixes #13471 for trunk

File:
1 edited

Legend:

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

    r15705 r15707  
    104104            if ( $redirect_url = get_permalink(get_query_var('p')) )
    105105                $redirect['query'] = remove_query_arg(array('p', 'post_type'), $redirect['query']);
    106             if ( get_query_var( 'page' ) ) {
    107                 $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
    108                 $redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
    109             }
    110106        } elseif ( is_single() && !empty($_GET['name'])  && ! $redirect_url ) {
    111107            if ( $redirect_url = get_permalink( $wp_query->get_queried_object_id() ) )
     
    178174            }
    179175        } elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false ) {
    180             $category = get_term_by('slug', get_query_var('category_name'), 'category');
     176            $category = get_category_by_path(get_query_var('category_name'));
    181177            $post_terms = wp_get_object_terms($wp_query->get_queried_object_id(), 'category', array('fields' => 'tt_ids'));
    182178            if ( (!$category || is_wp_error($category)) || ( !is_wp_error($post_terms) && !empty($post_terms) && !in_array($category->term_taxonomy_id, $post_terms) ) )
    183179                $redirect_url = get_permalink($wp_query->get_queried_object_id());
     180        }
     181
     182        // Post Paging
     183        if ( is_singular() && get_query_var('page') && $redirect_url ) {
     184            $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
     185            $redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
    184186        }
    185187
Note: See TracChangeset for help on using the changeset viewer.