Make WordPress Core

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)

#1 @DrewAPicture
14 years ago

  • Cc xoodrew@… added

#2 @kovshenin
14 years ago

  • Milestone Awaiting Review
  • Resolution → duplicate
  • Status new → closed

Duplicate of #17646.

Note: See TracTickets for help on using tickets.