Skip Navigation

[Resolved] Import custom post type with relationship via csv

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 7 years ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

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/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by RolandJ4481 7 years ago.

Assisted by: Luo Yang.

Author
Posts
#514183

After reading https://toolset.com/documentation/user-guides/how-to-import-content-into-wordpress-using-csv/ , it is not clear how to relate the new entry to a different custom post type.

For my example:
I have a csv list of products. These products (= custom post type) are related to departments (= custom post type) through a many-to-one relationship.
In my csv file, how do I relate the product in a row to a specific department? All departments have been created, so I do have access to their respective ids.

#514312

Dear Roland,

I don't think it is possible within CSV Importer plugin, since Types is using a custom field "_wpcf_belongs_[parent-cpt-slug]_id" to store the parent post IDs, and if the you import the parent post into the new website, the post ID is different from the original website, so the parent/child relationship will not work as expected.

I suggest you try these, import the posts of parent post types(products and department), then manually setup the "_wpcf_belongs_[parent-cpt-slug]_id" value, then import the child post type into the new website.

#514549

Thank you for your answer. I am not sure what you mean with your reference to "new" and "original" website. I have the data in Excel sheets and need to get it into a website.

It seems that it is selecting the correct department when using the "_wpcf_belongs_[parent-cpt-slug]_id" does somehow select the right department but I still need to go into the product and save before it shows up in my product list.

#514600

Ok, solved it. I made the mistake of using my department's post slug and not the actual post type's slug. So in my case, I needed to add a column

_wpcf_belongs_department_id

and populate the column with the id of the department post.

The forum ‘Types Community Support’ is closed to new topics and replies.

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