Don't parse cat query var twice. Don't include children for category__* queries. Props SergeyBiryukov. see #16152
git-svn-id: http://svn.automattic.com/wordpress/trunk@17246 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6a812fc677
commit
939d6de748
|
@ -1230,6 +1230,15 @@ class WP_Query {
|
||||||
*/
|
*/
|
||||||
var $is_post_type_archive = false;
|
var $is_post_type_archive = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether the tax query has been parsed once.
|
||||||
|
*
|
||||||
|
* @since 3.1.0
|
||||||
|
* @access private
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
var $parsed_tax_query = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets query flags to false.
|
* Resets query flags to false.
|
||||||
*
|
*
|
||||||
|
@ -1485,6 +1494,7 @@ class WP_Query {
|
||||||
$this->is_date = true;
|
$this->is_date = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->parsed_tax_query = false;
|
||||||
$this->parse_tax_query( $qv );
|
$this->parse_tax_query( $qv );
|
||||||
|
|
||||||
foreach ( $this->tax_query->queries as $tax_query ) {
|
foreach ( $this->tax_query->queries as $tax_query ) {
|
||||||
|
@ -1671,7 +1681,7 @@ class WP_Query {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Category stuff
|
// Category stuff
|
||||||
if ( !empty($q['cat']) && '0' != $q['cat'] && !$this->is_singular ) {
|
if ( !empty($q['cat']) && '0' != $q['cat'] && !$this->is_singular && !$this->parsed_tax_query ) {
|
||||||
$q['cat'] = ''.urldecode($q['cat']).'';
|
$q['cat'] = ''.urldecode($q['cat']).'';
|
||||||
$q['cat'] = addslashes_gpc($q['cat']);
|
$q['cat'] = addslashes_gpc($q['cat']);
|
||||||
$cat_array = preg_split('/[,\s]+/', $q['cat']);
|
$cat_array = preg_split('/[,\s]+/', $q['cat']);
|
||||||
|
@ -1684,8 +1694,10 @@ class WP_Query {
|
||||||
$cat = abs($cat);
|
$cat = abs($cat);
|
||||||
if ( $in ) {
|
if ( $in ) {
|
||||||
$q['category__in'][] = $cat;
|
$q['category__in'][] = $cat;
|
||||||
|
$q['category__in'] = array_merge( $q['category__in'], get_term_children($cat, 'category') );
|
||||||
} else {
|
} else {
|
||||||
$q['category__not_in'][] = $cat;
|
$q['category__not_in'][] = $cat;
|
||||||
|
$q['category__not_in'] = array_merge( $q['category__not_in'], get_term_children($cat, 'category') );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$q['cat'] = implode(',', $req_cats);
|
$q['cat'] = implode(',', $req_cats);
|
||||||
|
@ -1696,7 +1708,8 @@ class WP_Query {
|
||||||
$tax_query[] = array(
|
$tax_query[] = array(
|
||||||
'taxonomy' => 'category',
|
'taxonomy' => 'category',
|
||||||
'terms' => $q['category__in'],
|
'terms' => $q['category__in'],
|
||||||
'field' => 'term_id'
|
'field' => 'term_id',
|
||||||
|
'include_children' => false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1705,7 +1718,8 @@ class WP_Query {
|
||||||
$tax_query[] = array(
|
$tax_query[] = array(
|
||||||
'taxonomy' => 'category',
|
'taxonomy' => 'category',
|
||||||
'terms' => $q['category__not_in'],
|
'terms' => $q['category__not_in'],
|
||||||
'operator' => 'NOT IN'
|
'operator' => 'NOT IN',
|
||||||
|
'include_children' => false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1715,7 +1729,8 @@ class WP_Query {
|
||||||
'taxonomy' => 'category',
|
'taxonomy' => 'category',
|
||||||
'terms' => $q['category__and'],
|
'terms' => $q['category__and'],
|
||||||
'field' => 'term_id',
|
'field' => 'term_id',
|
||||||
'operator' => 'AND'
|
'operator' => 'AND',
|
||||||
|
'include_children' => false
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1773,6 +1788,8 @@ class WP_Query {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->parsed_tax_query = true;
|
||||||
|
|
||||||
$this->tax_query = new WP_Tax_Query( $tax_query );
|
$this->tax_query = new WP_Tax_Query( $tax_query );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue