We are going to set up a bidirectional relationship between an
event CPT (Custom Post Type) and
venue CPT, then see how related venue(s) can be shown on single event pages and related event(s) on single venue pages.
Editing an event (Event 1):
Editing the venue that's set for the above event (Venue 1):
A single event on the front end:
A single venue on the front end:
We shall also ensure that
- the Section having the related events/venues get output only if there's at least 1 published related event/venue.
- heading inside the Section says Events or Event depending on whether there are/is more than 1 or 1 related event and similarly, Venues or Venue.
Create both the CPTs using a plugin like CPT UI or otherwise.
Create a ACF field group for one of the CPTs (doesn't matter for which you do first) having a Relationship field.
In the "Filter by Post Type" field, select the other CPT.
This is a Pro members-only tutorial.
To get full access, login below or sign up for a Pro Account