I am importing a child post type and would like to have these posts link to their proper parent during import. I've created both the parent and the child posts and custom fields with WP-Types. I have successfully imported records for both custom post types. Both the child and parent posts will have the same title.
WP-All Import uses place holders for identifying the unique field during import, But only allows me to insert one of the imported fields into _wpcf_belongs_parent_id
There is a spot on the import interface where I can run PHP functions during the import and call them from the input field. What I need is a function that can return the post_ID of the parent post with the same title as the record I'm importing. I will then have the correct post_ID in the _wpcf_belongs_parent_id fields.
Languages: English (English )Chinese (Simplified) (简体中文 )
Timezone: Asia/Hong_Kong (GMT+08:00)
Yes, you are right, you will need to setup the custom feild "_wpcf_belongs_parent_id" value for each child post.
You can try with wordpress function get_page_by_title() to get the post ID by post title, see wordpress document: https://codex.wordpress.org/Function_Reference/get_page_by_title
Retrieves a post given its title.
OMG! I love you! I've been trying to solve this for weeks on my own!
Do I create the field '_wpcf_belongs_sample_id' as a custom field in AllImport or in Toolset?
Do I need to modify / replace '$sample_id' with anything? Eg. that's just not a placeholder?
Apologies for stupid questions in advance!
I should clarify.
I'm importing two different record sets each day to two different post types.
One parent post (Vet Practices) the other a child post (vets).
The only common field between the two imports is 'Practice Name' and that's the key to link the right vets to the right practice.
How would I change your script to make it work for my situation?
I'm really surprised this hasn't come up a lot more on here!!