Skip Navigation

[Resuelto] Post relationships for imported data

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:
How to import posts while maintaining post hierarchies.
Solution:
Not possible. If there is a parent and child post type, because post ids are only created once the data is imported, it is impossible to pre-assign the post id of the parent to the child (by adding the meta field _wpcf_belongs_to)
Relevant Documentation:

This support ticket is created hace 7 años, 11 meses. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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+01:00)

This topic contains 2 respuestas, has 2 mensajes.

Last updated by timE hace 7 años, 11 meses.

Assisted by: Nigel.

Autor
Mensajes
#404117

This problem is related to the creation of post relationships using existing relational data.

Some XML files are being created from data in another database. I'm then using "WP All Import" to import these data into custom post types and fields created within Types.

The problem I have is that the structure of parent/child post relationships is already present within the XML files.

e.g. The course with id=1234 (in one XML file) also has a field called modules="3456|4567|5678" which denotes which module id's (in another XML file) should be assigned to it.

I can import both files fine and get the list of posts within the "courses" and "modules" post types. I can also make a parent/child relationship between them using Types, but relationships have to be created manually for each parent / child.

Is there a way I can use the contents of the XML to actually assign the relationship straight away without having to do it manually?

I can import the modules field as a Taxonomy if that makes it any easier.

If you know of anyone who has done something similar or have any idea how to do this it's be appreciated.

Thanks
Tim

I can't find the option for debug information:
WP 4.5.2
Toolset Types 2.0.1
Toolset Views 2.0
Toolset Maps 1.1
Toolset Layouts 1.6
Toolset CRED 1.6
Toolset Access 2.0

#404178

Nigel
Supporter

Languages: Inglés (English ) Español (Español )

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

Hi Tim

I wish I had an easy answer for you, but I don't.

Here's the issue.

The parent/child relationship is recorded via a '_wpcf_belongs_parent-slug_id' meta field stored against the child post with the parent post id in the wp_postmeta database table.

When you import your content, the posts are made on the fly. You could try and update your data schema so that your child module posts have a meta field _wpcf_belongs_course_id, but you don't know what the parent post id is because it doesn't exist yet until you import the data.

You could perhaps write a custom script to do the importing for you, or you might be able to come up with a solution that looks something like:

1. import only your parent posts (courses)
2. export the parent posts, including their post ids
3. somehow update your child post data to add the post ids of their parents as the _wpcf_belongs meta field

How viable 3 is depends on where your data is coming from and how you manage it.

#404184

Hi Nigel

Thanks for the reply. Not what I was hoping for but I guess it'll do.

I guess the other option would be to make types look for its parent/child relationships in a different meta-field that comes from the XML, but that's beyond me I think.

I reckon I'm going to have to eschew the layouts options and just build custom post type templates/archives using the traditional child-theme method then, and just pull the modules another way.

Cheers
Tim

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