WordPress.org

Make WordPress Core

Ticket #20767: tag-cat-queried-obj.diff

File tag-cat-queried-obj.diff, 1.1 KB (added by wonderboymusic, 9 years ago)

Patch for WP_Query->get_queried_object

  • wp-includes/query.php

     
    29652965
    29662966                        $query = reset( $tax_query_in_and );
    29672967
    2968                         if ( 'term_id' == $query['field'] )
    2969                                 $term = get_term( reset( $query['terms'] ), $query['taxonomy'] );
    2970                         else
    2971                                 $term = get_term_by( $query['field'], reset( $query['terms'] ), $query['taxonomy'] );
     2968            if ( $this->is_tag ) {
     2969                $term = get_term( $this->get( 'tag_id' ), 'post_tag' );
     2970            } else if ( $this->is_category ) {
     2971                $term = get_term( $this->get( 'cat' ), 'category' );
     2972            } else {
     2973                if ( 'term_id' == $query['field'] )
     2974                    $term = get_term( reset( $query['terms'] ), $query['taxonomy'] );
     2975                else
     2976                    $term = get_term_by( $query['field'], reset( $query['terms'] ), $query['taxonomy'] );               
     2977            }
    29722978
    29732979                        if ( $term && ! is_wp_error($term) )  {
    29742980                                $this->queried_object = $term;