Relational field
Object relations in a meta field
The relationships between WordPress objects are treated with a normal meta field.
After selecting the relationship field type this box will appear:

From, to, relation
From the left to the right you have:
From - The first entity involved in the relation
To - The second entity involved in the relation
Relation - The relationship between the selected entities
If you select a Bidirectional reaction (see below) a new box called Inversed field on target post
will be displayed.

Choose the corresponding field type.
Automatically this field type will be set as a relationship one (inversed of the selected one).
Relationships types
One-to-One - Unidirectional - The current object can be related to one object
One-to-One - Bidirectional - The current object can be related to one object and there is an inversed field on the target object
One-to-many - Unidirectional - The current object can be related to many objects
One-to-many - Bidirectional - The current object can be related to many objects and there is an inversed field on the target object
Many-to-one - Unidirectional - Many objects belonging to the current object can be related to one object
Many-to-one - Bidirectional - Many objects belonging to the current object can be related to one object and there is an inversed field on the target object
Many-to-many - Unidirectional - Many objects belonging to the current object are related to many objects
Many-to-many - Bidirectional - Many objects belonging to the current object can be related to many objects and there is an inversed field on the target object
Example
Suppose you have two custom post types: one called Florist and one called Flower.
The Florist may have many flowers, and any flower belongs to only one Florist.
Create a field called flowers
on the Florist and a field called florist
on the Flower (create them as simple text).
Then, go to Florist and transform the flowers
fields in a One-to-many bidirectional relation:
Select Flower as From entity
Select Florist as To entity
Select One-to-many bidirectional as the relation
Select
florist
as field target
You are done! automatically on the Flower side, the florist
field is now a Many-to-one bidirectional relation.
Last updated