Make WordPress Core


Ignore:
Timestamp:
01/15/2014 07:33:23 AM (11 years ago)
Author:
nacin
Message:

Query: Fix category handling in pre_get_posts when pretty permalinks are in use (category_name query variable).

Merges [26864] [26874] [26875] to the 3.8 branch.

props wonderboymusic, SergeyBiryukov.
fixes #26627.

Location:
branches/3.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.8

  • branches/3.8/src/wp-includes/query.php

    r26525 r26946  
    32653265        if ( $this->is_category || $this->is_tag || $this->is_tax ) {
    32663266            if ( $this->is_category ) {
    3267                 $term = get_term( $this->get( 'cat' ), 'category' );
     3267                if ( $this->get( 'cat' ) ) {
     3268                    $term = get_term( $this->get( 'cat' ), 'category' );
     3269                } elseif ( $this->get( 'category_name' ) ) {
     3270                    $term = get_term_by( 'slug', $this->get( 'category_name' ), 'category' );
     3271                }
    32683272            } elseif ( $this->is_tag ) {
    32693273                $term = get_term( $this->get( 'tag_id' ), 'post_tag' );
     
    32723276                $query = reset( $tax_query_in_and );
    32733277
    3274                 if ( 'term_id' == $query['field'] )
    3275                     $term = get_term( reset( $query['terms'] ), $query['taxonomy'] );
    3276                 else
    3277                     $term = get_term_by( $query['field'], reset( $query['terms'] ), $query['taxonomy'] );
     3278                if ( $query['terms'] ) {
     3279                    if ( 'term_id' == $query['field'] ) {
     3280                        $term = get_term( reset( $query['terms'] ), $query['taxonomy'] );
     3281                    } else {
     3282                        $term = get_term_by( $query['field'], reset( $query['terms'] ), $query['taxonomy'] );
     3283                    }
     3284                }
    32783285            }
    32793286
Note: See TracChangeset for help on using the changeset viewer.