Opened 15 years ago
Closed 15 years ago
#13109 closed enhancement (fixed)
get_taxonomies should filter object_type
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Posts, Post Types | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
get_taxonomies should filter on the object_type to allow retrieving all taxonomies for a particular post_type. Example:
$args=array( 'object_type' => array('book','movie') ); $output = 'objects'; $taxonomies=get_taxonomies($args,$output);
Note: get_object_taxonomies('book'); does return the taxonomy names related to an object_type / post_type
Attachments (3)
Change History (16)
#2
@
15 years ago
To further filter the taxonomy objects you could do something like this:
`
$taxonomies = get_object_taxonomies('post', 'objects');
$taxonomies = wp_filter_object_list($taxonomies, array('_builtin' => false));
`
#3
@
15 years ago
- Keywords tested added
Thought you might change wp_filter_object_list to do that ;)
Okay tested that with both 'names' and 'objects' and it works.
Don't know why I had to apply that patch manually.
Thanks scribu.
#7
@
15 years ago
Had to make a small change, at least one place in trunk checked for the [0] key. If you want to re-patch core to assume that the key is a name, instead of numeric, then feel free to re-open.
#9
@
15 years ago
- Keywords tested removed
- Resolution fixed deleted
- Status changed from closed to reopened
We should have consistent behaviour between get_object_taxonomies() and get_taxonomies().
wp_filter_object_list.diff makes it so that get_taxonomies(, 'names') also returns a numeric array.
#10
@
15 years ago
Missing some brackets there.
I did a quick scan and couldn't find any other times we use a key from get_post_stati, get_taxonomies, or get_post_types.
#11
@
15 years ago
Even so, it doesn't make much sense to return something like this:
`
array(
[category] => category,
[post_tag] => post_tag,
...
)
`
I meant get_taxonomies('', 'names')
I often found it frustrating that get_object_taxonomies() only returned the taxonomy names.
Patch adds an $output parameter to get_object_taxonomies().