Skip Navigation

[Resolved] Duplicate Post – how to duplicate taxonomy.

This support ticket is created 5 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by ScottM9386 5 years, 6 months ago.

Assisted by: Waqar.

Author
Posts
#1135455

Hi,

I'm using code here and it works great:
https://toolset.com/forums/topic/retain-checkbox-and-relationship-value-when-duplicate-post-on-front-end/

but how do I
1. duplicate the custom taxonomies
2. duplicate the relationships
One of the relationships is Track-Writer (M2M) with an intermediary field.

I understand if this is venturing into hiring a contractor territory.

Thank you!!

#1135967

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Scott,

Thank you for contacting us and I'll be happy to assist.

Your understanding is correct and custom programming assistance is beyond the scope of the support that we provide. But we do our best to guide in the right direction, whenever possible.

1. If you'd like to duplicate the custom taxonomy terms attached to a post when it is submitted using the Toolset form, the following two steps will be involved:

a). First using a function attached to "cred_save_data" hook, (similar to https://toolset.com/forums/topic/retain-checkbox-and-relationship-value-when-duplicate-post-on-front-end/#post-948285 ), you'll get all the taxonomy terms attached to the post, through "get_the_terms" function:
https://developer.wordpress.org/reference/functions/get_the_terms/

b). To add the duplicates of each of those terms, you can then use "wp_set_post_terms" function:
https://codex.wordpress.org/Function_Reference/wp_set_post_terms

2. Likewise, it is possible to get information about the related posts and set new relationships, using the Toolset's "Post Relationship API":
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/

a). First, you'll use "toolset_get_related_posts" function to get information about the existing related posts:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

b). And then to set new duplicated relationships, you'll use "toolset_connect_posts" function:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts

For a more personalized assistance around custom code, you can consider hiring a professional from our list of certified consultants:
https://toolset.com/consultant/

I hope this helps.

regards,
Waqar

#1136119

Hi Waqar,

Above my head unfortunately. Guess I'll have to hire someone.
Thank you for the info though!

Regards,
Scott.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.