From 0adf04d6dbb3092d472eafc81cedd2c9b8531220 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Tue, 11 May 2010 16:50:25 +0000 Subject: [PATCH] Don't order term count queries. git-svn-id: https://develop.svn.wordpress.org/trunk@14563 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/taxonomy.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 9806106ecc..72cf574950 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -819,11 +819,18 @@ function &get_terms($taxonomies, $args = '') { $orderby = 't.slug'; else if ( 'term_group' == $_orderby ) $orderby = 't.term_group'; + else if ( 'none' == $_orderby ) + $orderby = ''; elseif ( empty($_orderby) || 'id' == $_orderby ) $orderby = 't.term_id'; $orderby = apply_filters( 'get_terms_orderby', $orderby, $args ); + if ( !empty($orderby) ) + $orderby = "ORDER BY $orderby"; + else + $order = ''; + $where = ''; $inclusions = ''; if ( !empty($include) ) { @@ -916,11 +923,13 @@ function &get_terms($taxonomies, $args = '') { $selects = array('t.term_id', 'tt.parent', 'tt.count', 't.name'); break; case 'count': + $orderby = ''; + $order = ''; $selects = array('COUNT(*)'); } $select_this = implode(', ', apply_filters( 'get_terms_fields', $selects, $args )); - $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where ORDER BY $orderby $order $limit"; + $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where $orderby $order $limit"; if ( 'count' == $fields ) { $term_count = $wpdb->get_var($query);