From ddae2a0b152dc3ce766d25e0aec1529e424ae53e Mon Sep 17 00:00:00 2001 From: dd32 Date: Sun, 17 Oct 2010 06:14:58 +0000 Subject: [PATCH] Prevent notices on non-existent Term locations (such as /tag/404-non-existant-term/) git-svn-id: http://svn.automattic.com/wordpress/trunk@15827 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/query.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index f4bc110f31..b1a0580211 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -2577,13 +2577,16 @@ class WP_Query extends WP_Object_Query { if ( !empty( $tax_query ) ) { $query = reset( $tax_query ); + 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'] ); - $this->queried_object = $term; - $this->queried_object_id = $term->term_id; + if ( $term && ! is_wp_error($term) ) { + $this->queried_object = $term; + $this->queried_object_id = $term->term_id; + } } elseif ( $this->is_posts_page ) { $page_for_posts = get_option('page_for_posts'); $this->queried_object = & get_page( $page_for_posts );