From 0c64fe335af5ec620a92fc3985929fdde99fa91c Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Mon, 6 Oct 2014 22:05:18 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@29845 git-svn-id: http://core.svn.wordpress.org/trunk@29608 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/taxonomy.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 5846844631..1b4902d650 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -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; }