Opened 3 years ago
Last modified 3 years ago
#13661 new enhancement
Support id=>name in fields arg of get_terms()
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Taxonomy | Version: | 3.0 |
| Severity: | normal | Keywords: | has-patch |
| Cc: | kevinB |
Description
In trying to use get_terms() I found it didn't support what seemed a common use case; an array where keys were $term->term_id and the values where $term->name.
This patch adds functionailty for a "id=>name" in fields arg of get_terms(). It returns array of term names keyed by the term id.
This path is similar to changeset:12729 by ryan on 2010-Jan-15.
I searched for a similar ticket but didn't find anything recently related.
Attachments (2)
Change History (5)
mikeschinkel — 3 years ago
mikeschinkel — 3 years ago
Adds a choice of "id=>name" and "id=>slug" for the "fields" argument passed as the 3rd parameter of get_terms() in /wp-includes/taxonomy.php. This choice makes the returned array from get_terms() contains array keys equal to $term->term_id and arrays values equal to $term->name, and array keys equal to $term->slug and arrays values equal to $term->name, respectively.
comment:1
mikeschinkel — 3 years ago
Ugh. Just as soon as I posted this I realize I really also needed slug=>name. New patch attached.

Add support for "id=>name" in "fields" arg of get_terms() function. Returns array of term names keyed by term id.