[wp-trac] [WordPress Trac] #31098: Filter wp_get_object_terms sends the wrong $taxonomies value

WordPress Trac noreply at wordpress.org
Wed Mar 27 21:14:17 UTC 2024


#31098: Filter wp_get_object_terms sends the wrong $taxonomies value
--------------------------+------------------------
 Reporter:  PhoenixML     |       Owner:  (none)
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:
Component:  Taxonomy      |     Version:  2.8
 Severity:  normal        |  Resolution:  duplicate
 Keywords:                |     Focuses:
--------------------------+------------------------

Comment (by vizvizka):

 It seems like there might be an issue with the way the $taxonomies
 variable is handled within the wp_get_object_terms() function in
 WordPress. This function is responsible for retrieving the terms
 associated with an object (such as posts or custom post types).

 add_filter('wp_get_object_terms', 'custom_get_object_terms', 10, 3);

 function custom_get_object_terms($terms, $object_ids, $taxonomies) {

     if (is_string($taxonomies)) {

         $taxonomies = explode(',', $taxonomies);

         $taxonomies = array_map('trim', $taxonomies);
     }

     return $terms;
 }

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/31098#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list