Skip Navigation

[Resolved] Export custom post type and it's relationships

This support ticket is created 5 years, 4 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 4 replies, has 2 voices.

Last updated by bartv-9 5 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#1335595

Tell us what you are trying to do?
I want to bulk connect custom posts. So for example I have 5 cars (post type cars) and I want to add the same relationship for all 5 cars to another post (for example post type blue). With wpallexport and wpallimport it works, but the problem is, that when I import the exported CSV and update the relationships, the old relationships are replaced by the new relationships. What I need is that they are added to the already existing relationships. This is possible, but for that I need to export the already exisiting relationship a post has to another post, but I can't seem to find out where.

#1335877

With wpallexport and wpallimport it works, but the problem is, that when I import the exported CSV and update the relationships, the old relationships are replaced by the new relationships. What I need is that they are added to the already existing relationships.
Hi, could I see your CSV documents? It will help me understand what you're trying to achieve here. I'm not clear from your description how the new relationships are added to the CSV files. It would be helpful for me to see the originals vs any modifications you made before import.

If that's okay, please post those files to Dropbox or Drive and share a download link for me here. All links you post in the forum are obscured from the public for your privacy.

#1336261

Hi Christian,

Yes ofcourse. The csv is super simple, see hidden link
It is that simple because I don't need to change anything, just add an extra relationship.

Than I import it and in step 3 I add the post that I want to connect the other posts to, see hidden link

This works, but it removes the already exisiting relations the posts already have. So I want to ADD a relation, not replace.

In the CSV there is only 1 post, so obviously for 1 post it's easier to do it directly in the dashboard, but I want to do this with many posts at a time, so the CSV would contain for example 50 posts.

#1336963

Got it, thanks. So you need a way to produce a list of existing child post IDs for each parent post in order to merge that information into the new relationships CSV file. This way the existing relationships will be maintained, and new relationships will also be added.

The easiest solution I can think of uses a View, not any export tools or plugins. Create a View of child posts, filtered by post relationship, where the parent post is set by the current post. Add the post ID shortcode in the loop so you will output the child post IDs. Insert this View in the parent post's template temporarily. Use commas in the loop to format the output so that when you copy this text from your site, you can simply paste it into the CSV file using a text editor. You should probably test this format without Views to confirm it works, then try to recreate that format with the View. As you create new CSV files to add new relationships to each parent post, copy + paste the results from the View into the new relationships CSV file.

If you're looking for a more challenging approach, I don't know of a built-in way to achieve this with our export tools. Generally to export post relationships, you will use the standard WordPress > Toolset > Export feature to export the child post type. This will produce an XML document containing all the relevant post information, including a meta key that represents the post relationship, and a meta value that corresponds to the parent post. So if you wanted to use this approach, you would need to be comfortable editing XML files and transforming the content into something you can copy + paste into a CSV file.

A third option is to use the PHP API toolset_export_associations_of_child-child_id to loop over all child posts and produce a list of existing relationships. You would then be able to merge those existing relationships in your new relationships CSV files. Obviously this requires a skilled PHP developer.
https://toolset.com/documentation/user-guides/importing-content-from-csv-with-post-relationships/#toolset_export_associations_of_child-child_id

Let me know if you have additional questions about these options.

#1337679

Thanks Christian. I actually found a plugin that can export relationships: hidden link

So that makes the whole thing work.

Thanks.