In get_terms(), select term taxonomy count for all values of 'fields'.

Not having the count caused queries with 'fields' values of 'id=>name' and
'id=>slug' to return incorrect results when querying a hierarchical taxonomy
with 'hide_empty=true'.

Includes unit tests for get_terms() when using various combinations of 'fields',
'hide_empty', and 'hierarchical' arguments.

Props technical_mastermind.
Fixes #29859.

git-svn-id: https://develop.svn.wordpress.org/trunk@29845 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Boone Gorges
2014-10-06 22:04:11 +00:00
parent 3fa30bdd37
commit e79c2e0c9e
2 changed files with 433 additions and 2 deletions
+2 -2
View File
@@ -1512,10 +1512,10 @@ function get_terms( $taxonomies, $args = '' ) {
$selects = array( 'COUNT(*)' );
break;
case 'id=>name':
$selects = array( 't.term_id', 't.name' );
$selects = array( 't.term_id', 't.name', 'tt.count' );
break;
case 'id=>slug':
$selects = array( 't.term_id', 't.slug' );
$selects = array( 't.term_id', 't.slug', 'tt.count' );
break;
}