Set 'taxonomy' and 'term' query vars for back-compat. Fixes #12659

git-svn-id: http://svn.automattic.com/wordpress/trunk@16381 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
scribu 2010-11-15 10:51:39 +00:00
parent 7cb5240bd6
commit cc72395bbb
2 changed files with 26 additions and 8 deletions

View File

@ -549,7 +549,8 @@ function wp_title($sep = '»', $display = true, $seplocation = '') {
// If there's a taxonomy
if ( is_tax() ) {
$tax = get_taxonomy( get_query_var('taxonomy') );
$term = get_queried_object();
$tax = get_taxonomy( $term->taxonomy );
$title = single_term_title( $tax->labels->name . $t_sep, false );
}

View File

@ -1943,13 +1943,30 @@ class WP_Query {
$where .= get_tax_sql( $q['tax_query'], "$wpdb->posts.ID" );
// Back-compat
$cat_query = wp_list_filter( $q['tax_query'], array( 'taxonomy' => 'category', 'operator' => 'IN' ) );
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 );
$tax_query_in = wp_list_filter( $q['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 );
}
}
}
}