Prevent notices on non-existent Term locations (such as /tag/404-non-existant-term/)

git-svn-id: https://develop.svn.wordpress.org/trunk@15827 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse 2010-10-17 06:14:58 +00:00
parent 20e3b23a80
commit a5da762a4e

View File

@ -2577,13 +2577,16 @@ class WP_Query extends WP_Object_Query {
if ( !empty( $tax_query ) ) { if ( !empty( $tax_query ) ) {
$query = reset( $tax_query ); $query = reset( $tax_query );
if ( 'term_id' == $query['field'] ) if ( 'term_id' == $query['field'] )
$term = get_term( reset( $query['terms'] ), $query['taxonomy'] ); $term = get_term( reset( $query['terms'] ), $query['taxonomy'] );
else else
$term = get_term_by( $query['field'], reset( $query['terms'] ), $query['taxonomy'] ); $term = get_term_by( $query['field'], reset( $query['terms'] ), $query['taxonomy'] );
$this->queried_object = $term; if ( $term && ! is_wp_error($term) ) {
$this->queried_object_id = $term->term_id; $this->queried_object = $term;
$this->queried_object_id = $term->term_id;
}
} elseif ( $this->is_posts_page ) { } elseif ( $this->is_posts_page ) {
$page_for_posts = get_option('page_for_posts'); $page_for_posts = get_option('page_for_posts');
$this->queried_object = & get_page( $page_for_posts ); $this->queried_object = & get_page( $page_for_posts );