In `WP_Query::get_queried_object()`, account for `pre_get_posts` by checking for `tag` when `tag_id` isn't present. Tags still need to be rolled up into `tax_query`. Add a unit test confirming expected query vars during and after `pre_get_posts`.

Props mattonomics for a patch.
See #27362.


Built from https://develop.svn.wordpress.org/trunk@27511


git-svn-id: http://core.svn.wordpress.org/trunk@27354 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-03-12 04:08:18 +00:00
parent d1008b2dfe
commit db1badfcab
1 changed files with 5 additions and 1 deletions

View File

@ -3663,7 +3663,11 @@ class WP_Query {
$term = get_term_by( 'slug', $this->get( 'category_name' ), 'category' );
}
} elseif ( $this->is_tag ) {
$term = get_term( $this->get( 'tag_id' ), 'post_tag' );
if ( $this->get( 'tag_id' ) ) {
$term = get_term( $this->get( 'tag_id' ), 'post_tag' );
} elseif ( $this->get( 'tag' ) ) {
$term = get_term_by( 'slug', $this->get( 'tag' ), '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 );