Make WordPress Core

Ticket #8948: multiple-terms.diff

File multiple-terms.diff, 1.3 KB (added by scribu, 15 years ago)

Don't redirect taxonomy unions or intersections

  • wp-includes/canonical.php

     
    135135                }
    136136
    137137                // Terms (Tags/categories)
    138                 if ( is_category() || is_tag() || is_tax() ) {
     138
     139                if ( (is_category() || is_tag() || is_tax()) ) {
     140
     141                        $has_multiple_terms = false;
     142                        foreach ( array('category__in', 'category__not_in', 'category__and', 'post__in', 'post__not_in',
     143                        'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and') as $key )
     144                                if ( count($wp_query->query_vars[$key]) > 1 ) {
     145                                        $has_multiple_terms = true;
     146                                        break;
     147                                }
     148
    139149                        $obj = $wp_query->get_queried_object();
    140                         if ( !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) && !is_wp_error($tax_url) ) {
    141150
     151                        if ( ! $has_multiple_terms && !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) && !is_wp_error($tax_url) ) {
     152
    142153                                $redirect['query'] = remove_query_arg( array( 'category_name', 'tag', 'cat', 'tag_id', 'term', 'taxonomy'), $redirect['query']);
    143154                                if ( is_tax() ) { // Custom taxonomies will have a custom query var, remove those too:
    144155                                        $tax = get_taxonomy( $obj->taxonomy );