For the complete documentation index, see llms.txt. This page is also available as Markdown.

Relational field

How to define typed relationships between WordPress objects using ACPT fields

"Relational" is not a standalone field type. It is a relationship feature that can be applied to Post, Term, and User object fields. When you configure a relationship on one of those fields, ACPT lets you define the cardinality and direction of the link between two WordPress entities.

To configure a relationship, select any Post, Term, or User object field and open its settings. The relationship panel 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 relation (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

Done. On the Flower side, the florist field is now automatically configured as a Many-to-one bidirectional relation.

Restrict to logged-in user posts

This option is available for Post, Post Multiple, and Relational fields.

Enabling Restrict to logged-in user posts in the field's advanced options filters the post selector so that it only lists posts authored by the currently logged-in user.

This is useful for front-end forms where editors or contributors should only be able to link their own content — for example, letting a user attach only their own "Portfolio" entries to a "Project" post, without seeing or selecting posts owned by other users.

Last updated