From f8338aa3c3e062621478b6501d56643961bb2935 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Fri, 27 Dec 2013 19:29:39 +0000 Subject: [PATCH] In `WP_Query::get_queried_object()`, move the check for `$query['terms']` to a place where `$query` is actually set. This should be included if [26864] makes it into 3.8.1. Props SergeyBiryukov. See #26728, [26864], #26634, #26627. git-svn-id: https://develop.svn.wordpress.org/trunk@26874 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/query.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/query.php b/src/wp-includes/query.php index d64a25a709..8d1f199210 100644 --- a/src/wp-includes/query.php +++ b/src/wp-includes/query.php @@ -3271,14 +3271,17 @@ class WP_Query { } } elseif ( $this->is_tag ) { $term = get_term( $this->get( 'tag_id' ), 'post_tag' ); - } elseif ( $query['terms'] ) { + } else { $tax_query_in_and = wp_list_filter( $this->tax_query->queries, array( 'operator' => 'NOT IN' ), 'NOT' ); $query = reset( $tax_query_in_and ); - if ( 'term_id' == $query['field'] ) - $term = get_term( reset( $query['terms'] ), $query['taxonomy'] ); - else - $term = get_term_by( $query['field'], reset( $query['terms'] ), $query['taxonomy'] ); + if ( $query['terms'] ) { + if ( 'term_id' == $query['field'] ) { + $term = get_term( reset( $query['terms'] ), $query['taxonomy'] ); + } else { + $term = get_term_by( $query['field'], reset( $query['terms'] ), $query['taxonomy'] ); + } + } } if ( ! empty( $term ) && ! is_wp_error( $term ) ) {