Skip Navigation

[Resolved] What is the custom field for CPT parent post relationship?

This thread is resolved. Here is a description of the problem and solution.

Problem:
How Types stores parent post ID of Types relationship in database

Solution:
The postmeta key that holds the parent field ID is: _wpcf_belongs_{parent-posttype-slug}_id

Where:
- Replace {parent-posttype-slug} with your original parent post type slug.

You can find proposed solution with the following reply:
=> https://toolset.com/forums/topic/what-is-the-custom-field-for-cpt-parent-post-relationship/#post-598429

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/how-to-import-content-into-wordpress-using-csv/import-content-csv-importer-plugin/#importing-types-post-relations

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 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 7 replies, has 2 voices.

Last updated by StanleyT8485 7 years ago.

Assisted by: Minesh.

Author
Posts
#598077

Tell us what you are trying to do?
I am trying to find the custom field for CPT parent post relationship. I am using an import plugin and every time I import my posts, it deletes the relationship. I am able to change the settings of this import plugin to disable importing the custom field for the parent post relationship but I don't know what the custom field is.

I tried wpcf-pr-belongs and wpcf_pr_belongs and both didn't work. It still cancels off the relationship.

Any ideas?

Thanks!

#598131

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - we have detailed Doc available to import your content using CSV.

The postmeta key that holds the parent field ID is: _wpcf_belongs_{parent-posttype-slug}_id
Where:
- Replace {parent-posttype-slug} with your original parent post type slug.

Please check this section "Importing Types Post Relations":
=> https://toolset.com/documentation/user-guides/how-to-import-content-into-wordpress-using-csv/import-content-csv-importer-plugin/#importing-types-post-relations

#598334

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Adding my comment here to set correct status for this ticket.

#598350

Thanks for the reply, Minesh.

Is there another custom field? Something more generic? Because I will be telling the plugin to not import that custom field for all the posts. If we use _wpcf_belongs_{parent-posttype-slug}_id, it will only work for 1 post but not for the rest.

#598368

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

No - there is no other custom field.

The format to store parent using Types relationship is fixed and predefined and its required to follow to get expected results.

#598421

How can we add parent-child relationship with custom field (without using the "Post Relationship" box created in Types)?

#598429

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - post relationship will be created either by using Types (GUI) or using custom PHP code.

As I already explained you:
The postmeta key that holds the parent field ID is: _wpcf_belongs_{parent-posttype-slug}_id
Where:
- Replace {parent-posttype-slug} with your original parent post type slug.

If you want to import Types Post Relations, When using Types posts relationships, the parent of a given type is stored as:

_wpcf_belongs_{parent-posttype-slug}_id

Let’s assume that we are displaying a Car post type (child post type) that has a Maker (parent post type) as a parent post type. Each Car will store its Maker id in the field _wpcf_belongs_maker_id in post meta table.

Parent Post ID cannot be “guessed” by the system. You first need to create your parent post and get its ID. Then you can use that ID to import child posts.

#598833

Thanks Minesh for your help. I have found another solution.