Skip Navigation

[Resolved] Where is parent post id stored in DB for O2O relationship

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

Problem:

1) get related posts using custom PHP codes.

2) Where is parent post id stored in DB for O2O relationship

Solution:

Please follow our document to setup your custom PHP codes:

https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post

If there are multiple related posts(O2M and M2M relationships), please check function toolset_get_related_posts()

https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

And the post relationship data are saved in your database tables:

- wp_toolset_associations
- wp_toolset_relationships
- wp_toolset_connected_elements

Relevant Documentation:

This support ticket is created 3 years, 11 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
- 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 5 replies, has 2 voices.

Last updated by himanshuS 3 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#1886165

I have "endorsement request" parent post type and a "endorsement" as a child post.
My endorsement is created and it is linked to the endorsement request. They are both in a O2O relationship.

As per documentation, I should be able to find parent id in the custom field _wpcf_belongs_endorsement-request_id. But that custom field does not exist when I search wp_postmeta table. In fact, this query (SELECT * FROM wp_postmeta where meta_key LIKE '%_wpcf%belong') returns no rows.

Use case: get a list of all endorsements that are published and have a parent that is created by the current user.

Documentation:
https://toolset.com/forums/topic/meta-for-post-relationships/
https://toolset.com/forums/topic/where-are-custom-fields-stored-in-the-database-wordpress-custom-query/

What am I missing here? Has the location for parent post id changed?

#1886179
53a49eed352ce9539b39b05bd3280fcf.png
a55585fdfa0d4ca3dd88430da9a9f42a.png

Screenshots attached.

#1886229

More info:
The endorsement is published by an unregistered user using a custom link. The urlparam for the parent endorsement request is used to populate the parent relationship in the endorsement form. You can see in the screenshot that the endorsement has a parent endorsement request linked to it.

#1886561

Hello,

You are referring outdated threads, I assume you are going to get related posts using custom PHP codes.
Please follow our document to setup your custom PHP codes :
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post

If there are multiple related posts(O2M and M2M relationships), please check function toolset_get_related_posts()
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts

And the post relationship data are saved in your database tables:
- wp_toolset_associations
- wp_toolset_relationships
- wp_toolset_connected_elements

#1887021

Luo,
Thanks for the information. This worked perfectly well. It would be great to remove or flag outdated threads as I spend a lot of time looking at those before filling a ticket.

#1887023

My issue is resolved now. Thank you!