Opened 12 years ago
Closed 12 years ago
#23894 closed defect (bug) (duplicate)
wp_get_object_terms returns an array of strings when asked for IDs
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Taxonomy | Keywords: | |
Focuses: | Cc: |
Description
When calling wp_get_object_terms
with the fields => 'ids'
argument, the function returns an array of IDs which are strings and not integers. The wp_set_object_terms
accepts an array of IDs, but if the IDs are strings, it results in a bunch of new terms. Here's a workaround:
$terms = wp_get_object_terms( $post_id, $taxonomy, array( 'fields' => 'ids ) ); $terms = array_map( 'absint', $terms ); // boo :( wp_set_object_terms( $other_post_id, $terms, $taxonomy );
Change History (2)
Note: See
TracTickets for help on using
tickets.
Duplicate of #17646.