Opened 14 years ago
Closed 14 years ago
#23894 closed defect (bug) (duplicate)
wp_get_object_terms returns an array of strings when asked for IDs
| Reported by: | kovshenin | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Taxonomy | Version: | |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Duplicate of #17646.