WordPress.org

Make WordPress Core

Ticket #13471: 13471.2.diff

File 13471.2.diff, 875 bytes (added by nacin, 9 years ago)

Original patch from glenn.

  • wp-includes/canonical.php

     
    180180
    181181                        }
    182182                } elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false ) {
    183                         $category = get_term_by('slug', get_query_var('category_name'), 'category');
     183                        $category = explode( '/', get_query_var( 'category_name' ) );
     184                        $category = get_term_by('slug', $category, 'category');
    184185                        $post_terms = wp_get_object_terms($wp_query->get_queried_object_id(), 'category', array('fields' => 'tt_ids'));
    185186                        if ( (!$category || is_wp_error($category)) || ( !is_wp_error($post_terms) && !empty($post_terms) && !in_array($category->term_taxonomy_id, $post_terms) ) )
    186187                                $redirect_url = get_permalink($wp_query->get_queried_object_id());