Let's say i have a post with post id "1"
and post with post id "2"
.
And i have a custom taxonomy named "my_taxonomy"
.
The post with post id "1" has: "term1","term2","term3"
selected for the "my_taxonomy"
terms.
And the post with post id "2"
has: "term3","term4","term5"
selected for the "my_taxonomy"
terms.
I want to programmatically copy the terms from first post to second so the post with post id "2"
will have: "term1","term2","term3"
selected for the "my_taxonomy"
terms now.
How can i do that the most "short coded way" ?
A note: both posts are a custom post type posts.
I tried:
wp_set_object_terms( '2', wp_get_object_terms( '1', 'my_taxonomy' ), 'my_taxonomy');
Doesn't seem to work.