X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/256a3b381f63716209b3527d0a14442ae570c283..refs/tags/wordpress-3.8.1:/wp-includes/query.php?ds=sidebyside diff --git a/wp-includes/query.php b/wp-includes/query.php index 1ec9566c..8bf292e1 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -115,7 +115,10 @@ function wp_reset_query() { */ function wp_reset_postdata() { global $wp_query; - $wp_query->reset_postdata(); + + if ( isset( $wp_query ) ) { + $wp_query->reset_postdata(); + } } /* @@ -3264,17 +3267,24 @@ class WP_Query { if ( $this->is_category || $this->is_tag || $this->is_tax ) { if ( $this->is_category ) { - $term = get_term( $this->get( 'cat' ), 'category' ); + if ( $this->get( 'cat' ) ) { + $term = get_term( $this->get( 'cat' ), 'category' ); + } elseif ( $this->get( 'category_name' ) ) { + $term = get_term_by( 'slug', $this->get( 'category_name' ), 'category' ); + } } elseif ( $this->is_tag ) { $term = get_term( $this->get( 'tag_id' ), 'post_tag' ); } 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 ) ) {