Skip to main content
added 11 characters in body
Source Link
mondi
  • 255
  • 1
  • 6

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.

UpdateI tried:

Will that work?

wp_set_object_terms( '2', wp_get_object_terms( '1', 'my_taxonomy' ), 'my_taxonomy');

Doesn't seem to work.

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.

Update:

Will that work?

wp_set_object_terms( '2', wp_get_object_terms( '1', 'my_taxonomy' ), 'my_taxonomy');

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.

deleted 7 characters in body
Source Link
mondi
  • 255
  • 1
  • 6

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.

Update: Will

Will that do the job:work?

wp_set_object_terms( '2', wp_get_object_terms( '1', 'my_taxonomy' ), 'my_taxonomy');

?

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.

Update: Will that do the job:

wp_set_object_terms( '2', wp_get_object_terms( '1', 'my_taxonomy' ), 'my_taxonomy');

?

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.

Update:

Will that work?

wp_set_object_terms( '2', wp_get_object_terms( '1', 'my_taxonomy' ), 'my_taxonomy');
added 156 characters in body
Source Link
mondi
  • 255
  • 1
  • 6

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.

Update: Will that do the job:

wp_set_object_terms( '2', wp_get_object_terms( '1', 'my_taxonomy' ), 'my_taxonomy');

?

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.

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.

Update: Will that do the job:

wp_set_object_terms( '2', wp_get_object_terms( '1', 'my_taxonomy' ), 'my_taxonomy');

?

Source Link
mondi
  • 255
  • 1
  • 6
Loading