else
$args['query_var'] = sanitize_title_with_dashes( $args['query_var'] );
$wp->add_query_var( $args['query_var'] );
+ } else {
+ // Force query_var to false for non-public taxonomies.
+ $args['query_var'] = false;
}
if ( false !== $args['rewrite'] && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) {
// Meta query support.
$join = '';
+ $distinct = '';
if ( ! empty( $args['meta_query'] ) ) {
$mquery = new WP_Meta_Query( $args['meta_query'] );
$mq_sql = $mquery->get_sql( 'term', 't', 'term_id' );
$join .= $mq_sql['join'];
$where .= $mq_sql['where'];
+ $distinct .= "DISTINCT";
}
$selects = array();
$join .= " INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id";
- $pieces = array( 'fields', 'join', 'where', 'orderby', 'order', 'limits' );
+ $pieces = array( 'fields', 'join', 'where', 'distinct', 'orderby', 'order', 'limits' );
/**
* Filter the terms query SQL clauses.
$fields = isset( $clauses[ 'fields' ] ) ? $clauses[ 'fields' ] : '';
$join = isset( $clauses[ 'join' ] ) ? $clauses[ 'join' ] : '';
$where = isset( $clauses[ 'where' ] ) ? $clauses[ 'where' ] : '';
+ $distinct = isset( $clauses[ 'distinct' ] ) ? $clauses[ 'distinct' ] : '';
$orderby = isset( $clauses[ 'orderby' ] ) ? $clauses[ 'orderby' ] : '';
$order = isset( $clauses[ 'order' ] ) ? $clauses[ 'order' ] : '';
$limits = isset( $clauses[ 'limits' ] ) ? $clauses[ 'limits' ] : '';
- $query = "SELECT $fields FROM $wpdb->terms AS t $join WHERE $where $orderby $order $limits";
+ $query = "SELECT $distinct $fields FROM $wpdb->terms AS t $join WHERE $where $orderby $order $limits";
// $args can be anything. Only use the args defined in defaults to compute the key.
$key = md5( serialize( wp_array_slice_assoc( $args, array_keys( $defaults ) ) ) . serialize( $taxonomies ) . $query );
$terms = wp_get_object_terms( $ids, $taxonomies, array(
'fields' => 'all_with_object_id',
- 'orderby' => 'none',
+ 'orderby' => 'name',
'update_term_meta_cache' => false,
) );
function update_term_cache( $terms, $taxonomy = '' ) {
foreach ( (array) $terms as $term ) {
// Create a copy in case the array was passed by reference.
- $_term = $term;
+ $_term = clone $term;
// Object ID should not be cached.
unset( $_term->object_id );