[wp-trac] [WordPress Trac] #41010: wp_get_object_terms() returns duplicate terms if more than one taxonomy is given in args

WordPress Trac noreply at wordpress.org
Mon Jun 12 13:34:33 UTC 2017


#41010: wp_get_object_terms() returns duplicate terms if more than one taxonomy is
given in args
--------------------------+-----------------------------
 Reporter:  mranner       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Taxonomy      |    Version:  4.8
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 // works correct

 $list = wp_get_object_terms([ 104627 ], [ 'produkte' ]);
 print_r($list);

 // returns all terms for produkte and herkunft and merges all terms
 related to the post

 $list = wp_get_object_terms([ 104627 ], [ 'produkte', 'herkunft' ]);
 print_r($list);

 Problem is unset( $taxonomies[ $index ] ) followed by $terms =
 array_merge( $terms, get_terms( $args ) );

 foreach ( $taxonomies as $index => $taxonomy ) {} iterates for all given
 taxonomies and leaves an empty  $taxonomies array. get_terms() with an
 empty array for $args['taxonomy'] returns "all" related terms and merges
 with the terms of the previews loop run.

 Michael

--
Ticket URL: <https://core.trac.wordpress.org/ticket/41010>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list