Set 'cat' query var for backwards compatibility. Fixes #15007
git-svn-id: http://svn.automattic.com/wordpress/trunk@15685 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
88868f5ba5
commit
70728369f9
|
@ -3033,7 +3033,7 @@ function wp_filter_object_list( $list, $args = array(), $operator = 'and', $fiel
|
||||||
$filtered = array();
|
$filtered = array();
|
||||||
|
|
||||||
foreach ( $list as $key => $obj ) {
|
foreach ( $list as $key => $obj ) {
|
||||||
$matched = count(array_intersect_assoc(get_object_vars($obj), $args));
|
$matched = count( array_intersect_assoc( (array) ($obj), $args ) );
|
||||||
if ( ('and' == $operator && $matched == $count) || ('or' == $operator && $matched <= $count) ) {
|
if ( ('and' == $operator && $matched == $count) || ('or' == $operator && $matched <= $count) ) {
|
||||||
if ( $field )
|
if ( $field )
|
||||||
$filtered[] = $obj->$field;
|
$filtered[] = $obj->$field;
|
||||||
|
|
|
@ -1948,6 +1948,21 @@ class WP_Query {
|
||||||
$where .= " AND $wpdb->posts.ID IN(" . implode( ', ', $ids ) . ")";
|
$where .= " AND $wpdb->posts.ID IN(" . implode( ', ', $ids ) . ")";
|
||||||
else
|
else
|
||||||
$where .= ' AND 0 = 1';
|
$where .= ' AND 0 = 1';
|
||||||
|
|
||||||
|
// Back-compat
|
||||||
|
if ( !empty( $ids ) ) {
|
||||||
|
$cat_query = wp_filter_object_list( $tax_query, array( 'taxonomy' => 'category' ) );
|
||||||
|
if ( !empty( $cat_query ) ) {
|
||||||
|
$cat_query = reset( $cat_query );
|
||||||
|
$cat = get_term_by( $cat_query['field'], $cat_query['terms'][0], 'category' );
|
||||||
|
if ( $cat ) {
|
||||||
|
$this->set('cat', $cat->term_id);
|
||||||
|
$this->set('category_name', $cat->slug);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unset( $ids );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty($q['meta_key']) ) {
|
if ( !empty($q['meta_key']) ) {
|
||||||
|
|
Loading…
Reference in New Issue