Relationship queries
Overview
Use relationship queries to display content linked through Advanced Custom Fields (ACF) Post Object or Relationship fields. This feature lets you automatically show related content such as linked posts, projects, or clients.
How relationship queries work
Divi Loop Extender reads post IDs stored in ACF relationship fields and dynamically replaces the default loop source with related content.
When Post Object / Relationship is selected under Relationship Type, the query retrieves post IDs from the chosen field and displays them as loop results.
- The query respects the direction of the link (forward or reverse).
- The selection mode determines how ACF fields are mapped.
- Standard filters such as Post Status, Order, and Filter by Author remain available for refining results.
This system allows flexible, dynamic related-content loops on single post templates.
Supported relationship field types
Field type | Description | Example use case |
---|---|---|
ACF Relationship | Allows multiple post selections and stores an array of post IDs. | Display related blog posts below an article. |
ACF Post Object | Returns one or multiple post references depending on field setup. | Link a “Project” to its “Client” post. |
Configuring relationship queries
- Enable Loop Element on the container where related content will display.
- Under Relationship Type, choose Post Object / Relationship.
- The Direction, Source ACF Field, and Selection Mode fields become visible.
Step 1: Set the direction
The Direction defines how the relationship is interpreted.
Option | Description | Example |
---|---|---|
From this post (forward) | Displays posts referenced in the current post’s ACF field. | A “Project” lists the “Team Members” stored in its team members field. |
To this post (reverse) | Displays posts that reference the current post in their own ACF field. | A “Client” shows all “Projects” that have the client set in their project client field. |
Step 2: Choose the Source ACF Field
The Source ACF Field dropdown lists all ACF Relationship and Post Object fields available in the current post type or related types.
Setting | Purpose | Example |
---|---|---|
Source ACF Field (Forward) | Used when the direction is “From this post (forward).” Pulls related IDs from a field on the current post. | Select related projects to show projects linked from the post. |
Source ACF Field (Reverse) | Used when the direction is “To this post (reverse).” Looks for posts where the current post ID appears in that field. | Select project client to find projects that reference this client. |
Step 3: Define the selection mode
The Selection Mode determines how Loop Extender identifies which ACF field to use.
Option | Description | Typical use |
---|---|---|
Specific | Lets you manually select one ACF relationship field from the dropdown (the Source ACF Field). | For static, defined relationships like related posts . |
Related | Dynamically detects matching fields across post types or inherits the field name from another loop using relationship logic. | For bi-directional or contextual relationships between loops. |
Step 4: Refine the query
- Sorting and orderby: Combine with ACF fields, dates, or custom keys for advanced control.
Example configurations
Example 1: Related posts using ACF Relationship field
- Post type: Blog posts
- Field name:
related posts
- Relationship type: Post Object / Relationship
- Direction: From this post (forward)
- Selection mode: Specific
- Loop output: Shows manually selected related posts at the end of each article.
Example 2: Client → Projects (reverse direction)
- Post type: Clients
- Field name:
project client
(stored in Project post type) - Relationship type: Post Object / Relationship
- Direction: To this post (reverse)
- Selection mode: Specific
- Loop output: Displays all projects linked to the current client using the reverse relationship.
Example 3: Team members by department
- Post type: Team Member
- Field name:
department link
- Relationship type: Post Object / Relationship
- Direction: From this post (forward)
- Selection mode: Related
- AND logic: On
- Loop output: Displays team members that share the same department relationship.