Don't do any taxonomy stuff if is_singular. See #15487
git-svn-id: http://svn.automattic.com/wordpress/trunk@16515 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
01942c8a6c
commit
cbd4ea48ca
|
@ -1593,19 +1593,17 @@ class WP_Query {
|
|||
);
|
||||
}
|
||||
|
||||
if ( !$this->is_singular() ) {
|
||||
foreach ( $tax_query as $query ) {
|
||||
if ( 'IN' == $query['operator'] ) {
|
||||
switch ( $query['taxonomy'] ) {
|
||||
case 'category':
|
||||
$this->is_category = true;
|
||||
break;
|
||||
case 'post_tag':
|
||||
$this->is_tag = true;
|
||||
break;
|
||||
default:
|
||||
$this->is_tax = true;
|
||||
}
|
||||
foreach ( $tax_query as $query ) {
|
||||
if ( 'IN' == $query['operator'] ) {
|
||||
switch ( $query['taxonomy'] ) {
|
||||
case 'category':
|
||||
$this->is_category = true;
|
||||
break;
|
||||
case 'post_tag':
|
||||
$this->is_tag = true;
|
||||
break;
|
||||
default:
|
||||
$this->is_tax = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1945,46 +1943,48 @@ class WP_Query {
|
|||
$search = apply_filters_ref_array('posts_search', array( $search, &$this ) );
|
||||
|
||||
// Taxonomies
|
||||
$this->tax_query = $this->parse_tax_query( $q );
|
||||
if ( !empty( $this->tax_query ) ) {
|
||||
$clauses = call_user_func_array( 'get_tax_sql', array( $this->tax_query, $wpdb->posts, 'ID', &$this) );
|
||||
if ( !$this->is_singular ) {
|
||||
$this->tax_query = $this->parse_tax_query( $q );
|
||||
if ( !empty( $this->tax_query ) ) {
|
||||
$clauses = call_user_func_array( 'get_tax_sql', array( $this->tax_query, $wpdb->posts, 'ID', &$this) );
|
||||
|
||||
$join .= $clauses['join'];
|
||||
$where .= $clauses['where'];
|
||||
$join .= $clauses['join'];
|
||||
$where .= $clauses['where'];
|
||||
|
||||
if ( $this->is_tax ) {
|
||||
if ( empty($post_type) ) {
|
||||
$post_type = 'any';
|
||||
$post_status_join = true;
|
||||
} elseif ( in_array('attachment', (array) $post_type) ) {
|
||||
$post_status_join = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Back-compat
|
||||
$tax_query_in = wp_list_filter( $this->tax_query, array( 'operator' => 'IN' ) );
|
||||
if ( !empty( $tax_query_in ) ) {
|
||||
if ( !isset( $q['taxonomy'] ) ) {
|
||||
foreach ( $tax_query_in as $a_tax_query ) {
|
||||
if ( !in_array( $a_tax_query['taxonomy'], array( 'category', 'post_tag' ) ) ) {
|
||||
$q['taxonomy'] = $a_tax_query['taxonomy'];
|
||||
if ( 'slug' == $a_tax_query['field'] )
|
||||
$q['term'] = $a_tax_query['terms'][0];
|
||||
else
|
||||
$q['term_id'] = $a_tax_query['terms'][0];
|
||||
|
||||
break;
|
||||
}
|
||||
if ( $this->is_tax ) {
|
||||
if ( empty($post_type) ) {
|
||||
$post_type = 'any';
|
||||
$post_status_join = true;
|
||||
} elseif ( in_array('attachment', (array) $post_type) ) {
|
||||
$post_status_join = true;
|
||||
}
|
||||
}
|
||||
|
||||
$cat_query = wp_list_filter( $tax_query_in, 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 );
|
||||
// Back-compat
|
||||
$tax_query_in = wp_list_filter( $this->tax_query, array( 'operator' => 'IN' ) );
|
||||
if ( !empty( $tax_query_in ) ) {
|
||||
if ( !isset( $q['taxonomy'] ) ) {
|
||||
foreach ( $tax_query_in as $a_tax_query ) {
|
||||
if ( !in_array( $a_tax_query['taxonomy'], array( 'category', 'post_tag' ) ) ) {
|
||||
$q['taxonomy'] = $a_tax_query['taxonomy'];
|
||||
if ( 'slug' == $a_tax_query['field'] )
|
||||
$q['term'] = $a_tax_query['terms'][0];
|
||||
else
|
||||
$q['term_id'] = $a_tax_query['terms'][0];
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$cat_query = wp_list_filter( $tax_query_in, 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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue