From a9c773061099fee825c35bf4507f0fae31d7003b Mon Sep 17 00:00:00 2001 From: Peter Westwood Date: Sun, 10 May 2009 07:57:07 +0000 Subject: [PATCH] Allow for custom ordering in get_terms(). Fixes #7539 props DD32. git-svn-id: https://develop.svn.wordpress.org/trunk@11250 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/taxonomy.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index e996477d4f..b70c5cb541 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -533,9 +533,10 @@ function get_term_to_edit( $id, $taxonomy ) { * * The list of arguments that $args can contain, which will overwrite the defaults: * - * orderby - Default is 'name'. Can be name, count, or nothing (will use - * term_id). - * + * orderby - Default is 'name'. Can be name, count, term_group, slug or nothing + * (will use term_id), Passing a custom value other than these will cause it to + * order based on the custom value. + * * order - Default is ASC. Can use DESC. * * hide_empty - Default is true. Will not return empty terms, which means @@ -678,9 +679,10 @@ function &get_terms($taxonomies, $args = '') { $orderby = 't.slug'; else if ( 'term_group' == $orderby ) $orderby = 't.term_group'; - else + elseif ( empty($orderby) || 'id' == $orderby ) $orderby = 't.term_id'; - $orderby = apply_filters( 'get_terms_orderby', $orderby, $args ); + + $orderby = apply_filters( 'get_terms_orderby', $orderby, $args ); $where = ''; $inclusions = '';