Skip Navigation

[Resolved] Bulk Assign Posts to Parent; Assign Posts to Parent Automatically

This thread is resolved. Here is a description of the problem and solution.

Problem:
Bulk Assign Posts to Parent; Assign Posts to Parent Automatically

Solution:
This needs a custom script but you can follow the guidance given with the following reply.

You can find the proposed solution, in this case with the following reply:
https://toolset.com/forums/topic/bulk-assign-child-posts-to-parent-post/#post-1247104

Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 7 replies, has 2 voices.

Last updated by andrewF-6 5 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#1246376

Tell us what you are trying to do?

I have a website where:
1. Posts are generated automatically via RSS feed;
2. We have a very large catalog of existing posts.
3. We have a existing parent CPT
4. The relationship for the child post types to the parent are One to Many
5. Selecting each post using the Relationship select tool is far too time consuming because it only allows me to select one at a time.

I am trying to:
1. Bulk assign existing Child posts to Existing Parent CPT;
2. Automatically assign auto-generated posts to a specific Parent CPT;

It would be also acceptable if I could:
1. Automatically assign Child Posts to a Parent post based on the Category Taxonomy
2. If I could multi select posts to assign to a Parent post from the Custom Posts Type All Items Page within the Toolset Menu

Is there any documentation that you are following?
I have checked past similar support posts but the responses are unclear or seem to require extensive PHP or reference importing the data - but in my case the data already exists within the system. Specifically:
1. https://toolset.com/forums/topic/bulk-assign-post-to-parent/
2. https://toolset.com/forums/topic/how-to-bulk-set-parent-cpt/

Is there a similar example that we can see?
Not that I know of and our site is under maintenance until we can solve this issue.

#1246499

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - there is no native way to bulk assign the parent.

But you should write some custom script that should do it. Toolset offers post relationship functions that help you to connect parent and child post.

You can use the post relationship function toolset_connect_posts().
=> https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts

Another way but its while importing the content using CSV and you can connect posts for one to many relationship:
=> https://toolset.com/documentation/user-guides/how-to-import-content-into-wordpress-using-csv/how-to-import-data-from-a-csv-file-using-the-wp-all-import-toolset-types-add-on-plugin/post-relationships/#example-2-one-to-many-relationships

#1246517

Dear Support / Minesh,

Thank you for the response.

I am not in the least bit familiar with PHP. I have a few questions:
1. Where would I place this code? In functions.php? In Code Snippets?
2. I see the example but can you provide a more specific implementation where I have the following scenario:
a. A One to Many Parent Child Post Relationships
b. Parent Post Called "Cars"
c. Child Post Called "Car-Posts"
d. My objective is to automatically link all "Car-Posts" Types Posts as Child Posts to each one's respective Parent Post called "Cars".

If you can provide a simple script and information on where I am to place this script that would be very helpful - I should be able to figure it out from there.

Thanks

#1246526

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

1. Where would I place this code? In functions.php? In Code Snippets?
=> Well - if you want to add the custom code, Toolset offers custom code section:
- https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

2. I see the example but can you provide a more specific implementation where I have the following scenario:
a. A One to Many Parent Child Post Relationships
b. Parent Post Called "Cars"
c. Child Post Called "Car-Posts"
d. My objective is to automatically link all "Car-Posts" Types Posts as Child Posts to each one's respective Parent Post called "Cars".

Well - the thing is that this needs total custom programming which is beyond the scope of our support policy. As a supporter, we need to work within the defined support boundary.

If you need custom programming for such a requirement, please feel free to contact our certified partners they will be happy to help you with your any custom programming need:
=> https://toolset.com/toolset-support-policy/

#1246533

Dear Minesh / Support,

I thank you for your reply but in fairness I do not think this response is appropriate.

What I am requesting clarification on the guidelines you provided me with a tangible use case. I could have, and did find, the guidelines written in the support site documentation however it is not clear.

I dont understand how Toolset could expect a large application to be built where it us not easily possible to bulk assign child posts to a parent.

If it can be done please show me beyond linking to another page on your website. We spend good money and wait considerable time for support and whilst I understand you cannot custom code for every client, that is not what I am requesting.

If you look through your support requests from 2012 to the present what I am requesting is a common request to which no clear straightforward response has been given.

In one post from 2013 I even note that the support person says the feature may be added to a future release.

I kindly ask you to reconsider your response and provide a bit more clarity into how this can be done for not only me but the many other paying customers that have inquired into the same issue.

Thank-you.

#1246600

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - the thing is that there is no issue to support you but again as a supporter, we need to work within the defined boundary.

I would suggest you to file the feature request for this feature that will go straight to the support manager. That's the only way to push for such a feature to be added.
=> https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

I see you shared few old links but as you may already be noticed there is no solution available and the old links are linked to the legacy post-relationship that belongs to Types 2.x.x and with Types, 3.x.x new post-relationship is implemented.
- https://toolset.com/forums/topic/bulk-assign-post-to-parent/
- https://toolset.com/forums/topic/how-to-bulk-set-parent-cpt/

This is the new post relationship API function you should use to connect parent with the child where you need to write such custom script as per your requirement and setup.
=> https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts

For example:

toolset_connect_posts( 'one-to-many-relationship-slug',222 ,999  );

Where:
- Replace one-to-many-relationship-slug with your one-to-many relationship slug
- 222 is parent post ID
- 999 is child post ID

I would like to admit here again that this cannot be done without a custom code solution.

Here you can see the function in action so at least you can see how its added to connect two posts (parent and child):
=> https://toolset.com/forums/topic/the-automatic-attachment-to-the-post-does-not-work/#post-1078741

I would like to end here and sorry again for not sharing the solution you want but it's such situation that I'm not allowed to write such custom code without permissions. Thank you for understanding.

#1247316

Dear Minesh,

My issue is now resolved thanks to the work of Christian:
https://toolset.com/forums/topic/bulk-assign-child-posts-to-parent-post/

I post this link here because he provided a code snippet and explanation that I was able to work with in a clear manner.

Regards

#1247322

My issue is resolved now. Thank you!

The resolution can be found at the following link:
https://toolset.com/forums/topic/bulk-assign-child-posts-to-parent-post/