Make WordPress Core

Opened 11 years ago

Closed 11 years ago

#23894 closed defect (bug) (duplicate)

wp_get_object_terms returns an array of strings when asked for IDs

Reported by: kovshenin's profile kovshenin Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords:
Focuses: Cc:


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)

#1 @DrewAPicture
11 years ago

  • Cc xoodrew@… added

#2 @kovshenin
11 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #17646.

Note: See TracTickets for help on using tickets.