I am trying to: create a true bi-directional relations between two different custom post types.
I have two CPTs -> Schools and Documents each with their own custom fields. I will be pre-populating the school data via importing 5,000 schools and their fields in a CSV file.
I need to set this up so that when someone creates a new document (in a front-end form), they can select a school, the school data is then linked to the document and able to be displayed on the document page. But, I also need the document (or list of documents if many are entered) to be displayed on the school pages.
Is it possible to set this up so that if I add a new document and select a school that the document relates to, the school will also show the document automatically without having to edit the school to link to the document as well manually?
How do I go about this?
Dear J S,
How do you setup the "bi-directional" post type relations?
For example, if the post type "Documents" is a child post type of "Schools", then there is a custom field "_wpcf_belongs_schools_id" in each child "Documents" post, which stores the value of parent "Schools" post ID, see our document:
https://toolset.com/documentation/user-guides/querying-and-displaying-child-posts/
section "Displaying child posts using Types PHP functions"
You will need to manually setup the field "_wpcf_belongs_schools_id" values in the CSV file