Opened 8 years ago
Last modified 21 months ago
#23635 new enhancement
get_objects_in_term - identify matching terms
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.5.1 |
Component: | Taxonomy | Keywords: | needs-patch needs-unit-tests |
Focuses: | Cc: |
Description
get_objects_in_term
is great for viewing taxonomy relationships for non-posts. However the return value is too limited for certain use cases. For When fetching object_ids for multiple terms the return value doesn't inform as to the matching term.
For instance this query:
$object_ids = get_objects_in_term(array(55, 66, 77, 88, 99), "my_custom_taxonomy");
Might return an array of object_ids as follows:
array(101, 202, 303, 404);
However there's no way to tell which term a particular object_id matched. Did object 101 match term 77? Or maybe it was term 99? Or both?
I've created a modified version of get_objects_in_term
which will addresses this issue. I'll submit a patch, but am wondering if there's another way to achieve this functionality.
Change History (2)
Note: See
TracTickets for help on using
tickets.
Only by looping over each of your terms and calling
get_objects_in_term( $term_id )
for each.I can imagine supporting something like
$args['format']
that lets you specify that you'd like the results returned as an array: