mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-29 15:47:38 +02:00
Fix a regression for get_queried_object()
by checking for category_name
when cat
isn't set - mainly is_category()
being true for Uncategorized or when queried object is accessed in pre_get_posts
. Also check for $query['terms']
when trying to assign a term as the queried object when is_tax()
is true. Adds a unit test. See [26007] for how I originally broke this while fixing a bigger issue.
Props Chouby, jeremyfelt. Fixes #26634, #26627. Built from https://develop.svn.wordpress.org/trunk@26864 git-svn-id: http://core.svn.wordpress.org/trunk@26750 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
88952445cf
commit
014007f029
@ -3264,10 +3264,14 @@ class WP_Query {
|
|||||||
|
|
||||||
if ( $this->is_category || $this->is_tag || $this->is_tax ) {
|
if ( $this->is_category || $this->is_tag || $this->is_tax ) {
|
||||||
if ( $this->is_category ) {
|
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 ) {
|
} elseif ( $this->is_tag ) {
|
||||||
$term = get_term( $this->get( 'tag_id' ), 'post_tag' );
|
$term = get_term( $this->get( 'tag_id' ), 'post_tag' );
|
||||||
} else {
|
} elseif ( $query['terms'] ) {
|
||||||
$tax_query_in_and = wp_list_filter( $this->tax_query->queries, array( 'operator' => 'NOT IN' ), 'NOT' );
|
$tax_query_in_and = wp_list_filter( $this->tax_query->queries, array( 'operator' => 'NOT IN' ), 'NOT' );
|
||||||
$query = reset( $tax_query_in_and );
|
$query = reset( $tax_query_in_and );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user