[wp-trac] [WordPress Trac] #23894: wp_get_object_terms returns an array of strings when asked for IDs
WordPress Trac
noreply at wordpress.org
Fri Mar 29 12:56:04 UTC 2013
#23894: wp_get_object_terms returns an array of strings when asked for IDs
-----------------------------+--------------------------
Reporter: kovshenin | Type: defect (bug)
Status: new | Priority: normal
Milestone: Awaiting Review | Component: Taxonomy
Version: | Severity: normal
Keywords: |
-----------------------------+--------------------------
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 );
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/23894>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list