Skip to main content
Moved array from wp_set_object_terms() to wp_get_object_terms()
Source Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459

This will work:

wp_set_object_terms( 
    '2', 
    wp_get_object_terms( 
        '1', 
        'my_taxonomy', 
        array("fields"=>"ids") 
    ), 
   'my_taxonomy' 
);

Explanation:

I added this: ,array("fields"=>"ids") to the attempt i wrote in the question to make the wp_get_object_terms return array of ids alone (what the wp_set_object_terms want to get.

This will work:

wp_set_object_terms( '2', wp_get_object_terms( '1', 'my_taxonomy', array("fields"=>"ids") ), 'my_taxonomy');

Explanation: added this: ,array("fields"=>"ids") to the attempt i wrote in the question to make the wp_get_object_terms return array of ids alone (what the wp_set_object_terms want to get.

This will work:

wp_set_object_terms( 
    '2', 
    wp_get_object_terms( 
        '1', 
        'my_taxonomy', 
        array("fields"=>"ids") 
    ), 
   'my_taxonomy' 
);

Explanation:

I added this: ,array("fields"=>"ids") to the attempt i wrote in the question to make the wp_get_object_terms return array of ids alone (what the wp_set_object_terms want to get.

Moved array from wp_set_object_terms() to wp_get_object_terms()
Source Link

This will work:

wp_set_object_terms( '2', wp_get_object_terms( '1', 'my_taxonomy' ), 'my_taxonomy',array("fields"=>"ids") ), 'my_taxonomy');

Explanation: added this: ,array("fields"=>"ids") to the attempt i wrote in the question to make the wp_get_object_terms return array of ids alone (what the wp_set_object_terms want to get.

This will work:

wp_set_object_terms( '2', wp_get_object_terms( '1', 'my_taxonomy' ), 'my_taxonomy',array("fields"=>"ids"));

Explanation: added this: ,array("fields"=>"ids") to the attempt i wrote in the question to make the wp_get_object_terms return array of ids alone (what the wp_set_object_terms want to get.

This will work:

wp_set_object_terms( '2', wp_get_object_terms( '1', 'my_taxonomy', array("fields"=>"ids") ), 'my_taxonomy');

Explanation: added this: ,array("fields"=>"ids") to the attempt i wrote in the question to make the wp_get_object_terms return array of ids alone (what the wp_set_object_terms want to get.

Source Link
mondi
  • 255
  • 1
  • 6

This will work:

wp_set_object_terms( '2', wp_get_object_terms( '1', 'my_taxonomy' ), 'my_taxonomy',array("fields"=>"ids"));

Explanation: added this: ,array("fields"=>"ids") to the attempt i wrote in the question to make the wp_get_object_terms return array of ids alone (what the wp_set_object_terms want to get.