|Reported by:||filosofo||Owned by:|
|Component:||General||Keywords:||has-patch get_terms taxonomy children _get_term_children|
There are a couple of problems with get_terms:
- If the 'child_of' argument is 0 and 'hierarchical' is true (the defaults), then terms that have non-zero parent terms are disregarded, thanks to the following line: $terms = & _get_term_children($child_of, $terms, $taxonomies);
Because $child_of == 0 and such terms have a non-zero parent, _get_term_children excludes them.
- get_terms allows you to select fields "ids" or "names," in which case it currently uses $wpdb->get_col to get an array of those values. However, later get_terms attempts to count child terms (if appropriate) and weed out empty terms (if appropriate). But it fails to do so in the case when 'fields' is set to 'ids' or 'names'.
My patch fixes these issues. It gets term objects from the database no matter what, so the results are consistent no matter what fields are requested, and _get_term_children is more efficient, because it's not retrieving object info for every term.
I've also made the phpdoc descriptions a little more helpful.