Linked Posts
Written by the Divi Engine Documentation Team
Introduction
Follow these steps to learn about linking posts together with Divi Machine and ACF.
What Are Linked Posts?
Linked Posts are when two Post Types are linked.
For example, the Agent CPT and Property CPT.
Another example could be related posts based on another CPT.
For example, the Agent CPT and Property CPT.
Another example could be related posts based on another CPT.
How they can be used?
There are two ways that linked posts can be used - linked or related.
1. Linked Post Types
The idea here is to link one post with another to show the data from the other post on the current post.
- Show ALL CPT 1 assigned to CPT 2
Example: Show all Cars that are assigned to a specific Dealer - Show CPT 2 that is linked to current CPT 1
Example: Show the Dealer/s that are assigned to the current Car
2. Related Linked Posts
The idea here is to show posts that are related to the current post based on the post object.
-
Related Linked Post
Show more CPT 1 posts that have the same CPT 2 assigned
Example: Show other Cars from the same Dealer -
Specific Posts
Show more CPT 1 posts that you choose in the settings
Example: Show other Cars that you specify
How to set it up?
Global - what to set up for all cases
Step 1: Create Two Custom Posts
- Create two post types. For example, Cars (CPT 1) and Dealers (CPT 2).
Step 2: Create ACF Post Object Field
- Add a new ACF Field to your CPT 1 (Cars)
- Call this Post Object what you want, it would make sense to name it the same as CPT 2 (Dealer)
- “Filter by Post Type” - choose the CPT 2 here so that it filters out other CPT and only shows the Dealers for example to choose from.
Step 3: Assign CPT 2 to CPT 1
- Go to your post in CPT 1 (Car) and assign the CPT 2 (Dealer) that it is linked to.
Now you have them linked - this is the first step!
Linked Post Types
A) Show ALL CPT 1 assigned to CPT 2 (Show all Cars that are assigned to a specific Dealer)
Step 1: Create Theme Builder layout for CPT 2 Single Page (All Dealers)
Step 2: Add Archive Loop module to the Body of the template
Archive Loop Settings
- Main Options Toggle
- Post Type: Choose CPT 1 (Cars)
- Custom Loop Layout: Choose your custom loop layout
- Loop Options Toggle
- Post Display Type: Linked Post
- Linked Post Object ACF Name: Choose the ACF Post Object you made in Step 2 of the global set up stage above
B) Show CPT 2 that is linked to current CPT 1 (Show the Dealer/s that are assigned to the current Car)
Step 1: Create Theme Builder layout for CPT 1 Single Page (All Cars)
You can use either the ACF Item or Archive Loop module for this step.
Step 2: Add Archive Loop module to the Body of the template
Archive Loop Settings
- Main Options Toggle
- Post Type: Choose CPT 2 (Dealers)
- Custom Loop Layout: Choose your custom loop layout
- Loop Options Toggle
- Post Display Type: Linked Post
- Linked Post Object ACF Name: Choose the ACF Post Object you made in Step 2 of the global set up stage above
OR
Step 2: Add ACF Item module to the Body of the Template
ACF Item Settings
- Main Options Toggle
- ACF Field Type: Choose the ACF Post Object you made in Step 2 of the global set up stage above
- Relational Field Settings
- Relational Field Style
- Custom Loop Layout (you define the content)
- Comma-Separated List: We will output the titles of the CPT 2 that is linked (output Dealer/s names comma-separated)
- If Custom Loop Layout
- Relational Field Loop Layout: Choose your custom loop layout
- Grid Column settings for desktop, tablet and mobile appear
- If Comma-separated list
- List Separator: Define how each CPT 2 will be separated - you can use “,” or “|” etc
- Relational Field Style
Related Posts
A) Related Linked Post (Show other Cars from the same Dealer)
Step 1: Create Theme Builder layout for CPT 1 Single Page (All Cars)
Step 2: Add Archive Loop module to the Body of the template
Archive Loop Settings
- Main Options Toggle
- Post Type: Choose CPT 1 (Cars)
- Custom Loop Layout: Choose your custom loop layout
- Loop Options Toggle
- Post Display Type: Related
- Related Content: Post Object
- Post Object ACF Name: Choose the ACF Post Object you made in Step 2 of the global set up stage above
B) Specific Posts (Show other Cars that you specify)
Step 1: This one requires a slight change in the global set up above.
- Instead of Choosing CPT 2 (choose the dealer the car is linked to)
- Change it so they choose CPT 1 (choose other cars that this car is linked to)
Step 2 Create Theme Builder layout for CPT 1 Single Page (All Cars)
Step 3: Add Archive Loop module to the Body of the template
Archive Loop Settings
- Main Options Toggle
- Post Type: Choose CPT 1 (Cars)
- Custom Loop Layout: Choose your custom loop layout
- Loop Options Toggle
- Post Display Type: Related
- Related Content: Post Object
- Post Object ACF Name: Choose the ACF Post Object you made in Step 2 of the global set up stage above
More Support?
Please email us at [email protected] if you are unable to get Divi Machine working.