When we want to display related posts it is important to understand what content we are “currently displaying”. Depending on this, there are different ways of displaying items related to this content.
The following table makes this easier to understand.
What we want to achieve | Example |
---|---|
When displaying a single post, display information about one related post. | ![]() |
When displaying a single post, display multiple related posts. | ![]() |
When displaying a single post, display multiple related posts and include information from the intermediary post type that connects two main post types. | ![]() |
Watch the video – How to Create Post Relationships with Toolset
Workflows mentioned above allow you to display information about posts that are “one step away” from the current one. However, sometimes, you will need to display information from posts that are further away, for example, a child post of a child post. This is done a bit differently and you can find more information in the Examples section below.
Displaying one related item (parent)
When we say “one,” we mean items that are connected as “one-to-many” and are on the “one” side. An airport in the departures relationship is a good example of this. One airport has many departures.
Let’s go through the steps to do this.
Using Layouts
- In this example, first, edit the template layout that is used to display flights.
- Add a Visual Editor cell to this layout. Click on the Fields and Views button to insert a field Into the cell. The field can come from either departure or arrival airport. For example, you can insert a “Post title with a link” field.
- Click on the Post selection tab, then select A post related to the current post, set by a Types relationship option, and choose the relationship.
- You will see the shortcodes for these fields with the item attribute set to the relationship.
Using Views only
- In this example, first edit the template that is used to display flights.
- Click on the Fields and Views button to insert a field that comes from either the departure or arrival airport. For example, you can insert a “Post title with a link” field.
- Click on the Post selection tab, then select A post related to the current post, set by a Types relationship option, and choose the relationship.
- You will see the shortcodes for these fields with the item attribute set to the relationship.
Displaying many related items
In Toolset, every time you need to display a list of items, you must use a View. The same is true when you need to display “many” related items.
Let’s go through the steps to do this.
- Create a View. If you are using Toolset Layouts, insert a View cell into it. If you are not using Layouts, add a new View from the Toolset -> Views page.
- Set the View to load the “many” post type (in our example, flights).
- Add a Post Relationship filter to the Query Filter section and select the relationship by which you want to filter.
- Design your display for the items in the View using the Loop Output section.
- Insert this View into the template used to display the “one” side (in our example, the template for the airport).
View created as a cell inside a template layout | View inserted into a Content Template |
![]() |
![]() |
Displaying information from intermediary post types
Many-to-many relationships feature a so-called intermediary post type which connects two main types in a relationship. For example, Albums and Songs are connected by a post type called Album Tracks. These connecting post types can feature their own custom fields and you will sometimes need to display them.
In our example, when viewing an Album post, we want to list Songs that belong to it and display a Track Number for each song.
Let’s go through the steps to do this.
- Create a View. If you are using Toolset Layouts, insert a View cell into it. If you are not using Layouts, add a new View from the Toolset -> Views page.
- Set the View to load the intermediary post type (in our example, Album Tracks).
- Add a Post Relationship filter to the Query Filter section and select the relationship by which you want to filter.
- Design your display for the items in the View using the Loop Output section. Remember, you are listing posts of the intermediary post type. For post fields that belong to the main related post types, in our example Songs and Albums, you need to set the appropriate post selection options.
- Insert this View into the template used to display the “one” side (in our example, the template for the airport).
View created as a cell inside a template layout | View inserted into a Content Template |
![]() |
![]() |
Examples
As mentioned, sometimes you need to display information from posts that are not directly related to the current post. The following two pages provide examples of how to achieve this:
Toolset also features a special custom field called Post Reference. It allows you to easily connect two posts and display their related post information. You can read more about this on the page about using Post Reference Field To Display Data Of Related Posts.
Or, you can skip ahead to the page about building front-end forms for connecting posts.