Skip Navigation

[Resolved] What is current recommended way to to import csv parent and child posts

This support ticket is created 5 years, 10 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 11 replies, has 2 voices.

Last updated by Nigel 5 years, 5 months ago.

Assisted by: Nigel.

Author
Posts
#1196855

Tell us what you are trying to do?
I want to import parent and child posts using csv file - I'm using Danis Kobozev's CSV Importer plugin

Is there any documentation that you are following?
I would like to read the current documentation/tutorials including an example csv file - Please can you point me to relevant links
Thanks for your help
David

#1197111

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi David

Because relationships are stored in custom tables you need an importer that is aware of Types relationships, or you will need to connect the related posts manually.

Here's a guide using WP All Import with a Types relationship add-on: 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

#1197192

Thanks for your reply,
I've already loaded the parent posts. I now want to load the child posts using a csv file. Can I specify in the child posts csv file the parent post id each child post is connected to.
Please can you give me example of the csv file with content and headings

Thanks
David

#1197373

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi David

When we first updated Types to the new relationships I recall a feature to import posts and connect to parents if they were already present on the site, but I'm having trouble getting it to work (I think I maybe did this once before, many months ago).

I can clarify with the Types devs what's required in the morning meeting, so I'll speak to them then and then update you.

Sorry for the delay.

#1197431

Thanks Nigel, Much appreciated.
There's alot of Toolset documentation, my problem is there's no dates, and often no indication from which version it applies, I think this is something that needs to be addressed.

I noticed that with relationships a list of all the children are kept on the parent post, in the case of one to many relationships, seems more logical (and easier) that each child post contains one parent post id, which is why I'm asking about the method before relationships.

Thanks for your help
David

#1197804

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi David

OK, I set up a test site and successfully imported posts into a one-to-many relationship and other posts into a many-to-many relationship (with an intermediate post type to store relationship fields), and although I had to carefully follow the directions in our documentation, it worked like a charm, first go.

So, our documentation describes doing this with paid plugins that have created add-ons for Types relationships, but you can do it with any simple CSV importer that lets you specify the post type as one of the CSV columns.

I used the free hasn't-been-updated-for-4-years-but-still-does-the-job-with-no-frills CSV importer plugin: https://wordpress.org/plugins/csv-importer/

Now the specifics of how you should lay out the CSV file and the steps for this are described here: https://toolset.com/documentation/user-guides/importing-content-from-csv-with-post-relationships/

Note that this particular plugin requires that the standard post fields are prefixed with csv_, and, oddly, the heading for post_content needs to be csv_post_post.

You can see the file I prepared here: hidden link

Let me describe my set up.

I have a project-task one-to-many relationship (whose relationship slug is project-task). In that file I'm importing some project posts, some task posts, and I connect the task posts to the parent projects by including the title of the project in the column "_toolset_associations_project-task".

wpcf-source is just a sample Types custom field that I included for testing.

Now, when I import this CSV file using the CSV Importer the posts are created and the child posts have _toolset_associations_project-task custom fields added.

These exist only for the purposes of connecting related posts after an import.

So the final step is to go to Toolset > Export / Import and the Associations tab, which will then process these custom fields and set up the actual relationships.

I also have a more complex example, where I have a typical events-artists many-to-many relationship that uses an intermediate post type to store appearance details (in this case, the day of the week of the performance). My relationship (and the intermediate post type) have a slug of "appearance".

So in the CSV file there is a column _toolset_associations_appearance. For the child post rows (which means the right-hand side of a many-to-many relationship) I specify the title of the parent post and the intermediate post it should be connected to, in the very particular format you see in the file and which is described in the documentation.

In my example I'm importing all of this in one go.

If you already have parent posts imported you can just import the child posts, adding the relationship column that specifies the title of the parent post they belong to, and then complete the import from the associations tab of the settings page as described above.

#1197921

Hi Nigel, Thanks for the detailed explanation, much appreciated.
One question - at the moment, you say:
"If you already have parent posts imported you can just import the child posts, adding the relationship column that specifies the title of the parent post they belong to"

Is it correct that I can use the parent post title or the parent post id? If so would I include the post id in the same format as the post title, just replacing the post title with the post id?

Thanks for your help
David

#1198011

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

According to the documentation you can use the post title, or the GUID, not the post ID (although that does seem to be an option on at least one of the paid plugin options).

#1198026

Hi Nigel,
Can you explain what's the Post ID and the GUID and where can I find them.
I have this url for a parent post in the wp-admin:

hidden link

Is 6456 the Post ID, if so where do I find the GUID

Thanks
David

#1198498

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi David

GUID is the title of one of the columns in wp_posts, it is effectively the permalink for the post, which you can see beneath the title on the post edit screen.

GUID is provided as an alternative to post_title because, unlike the title, it must be unique.

Yes, 6456 in your example is the post ID (but that is only an option with the paid import plugins).

#1297267
relationship.JPG
relationship-csv.JPG

Hi Nigel,
I have 2 post types - plant and (medical) complaint all posts already exist.
Every complaint is treated by one or more of the plants, I now need to import a csv file to create the relationship / association so I can display the plants with the complaints they're used to treat.
The screenshots show an example of existing posts. I'm using the free csv importer plugin.
Very much appreciate if you could show me the correct csv and column headings for the posts in the attached example - I'd prefer to use the post id instead of post title if possible.
Let me know if I should open a new thread for this.
Thanks for your help
David

#1297359

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi David

I notice you have another thread with Waqar about this, so I'll close this again.

(I have meetings first thing and so am marked as unavailable to take new issues then, which is why you would not have been able to choose to assign the chat to me.)