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.

Details

When displaying a single post, display multiple related posts.

Details

When displaying a single post, display multiple related posts and include information from the intermediary post type that connects two main post types.

Details

 

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.

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.

Read documentation for version with:

Using Layouts

  1. In this example, first, edit the template layout that is used to display flights.

  1. 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.

  1. 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.

  1. You will see the shortcodes for these fields with the item attribute set to the relationship.

Using Views only

  1. In this example, first edit the template that is used to display flights.

Editing a Template of a Child Post

  1. 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.

  1. 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.

  1. You will see the shortcodes for these fields with the item attribute set to the relationship.

Post Fields That Display Information From The Parent Post

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.

  1. 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.

  1. Set the View to load the “many” post type (in our example, flights).

Selecting Post Types to List Posts From
Selecting Post Types to List Posts From

  1. Add a Post Relationship filter to the Query Filter section and select the relationship by which you want to filter.

  1. Design your display for the items in the View using the Loop Output section.

Designing How A View Outputs The Posts

  1. 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
A View Inserted Into A 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.

  1. 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.

  1. Set the View to load the intermediary post type (in our example, Album Tracks).

  1. Add a Post Relationship filter to the Query Filter section and select the relationship by which you want to filter.

  1. 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.
A.) In the Loop Wizard, click the Edit button for fields that belong to the main related post type (Songs).
B.) Click the Post selection tab and select the A post related to current post, set by a Types relationship option and select the relationship in question (Album Tracks).
  1. 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:

  1. Displaying Related Child Posts
  2. Displaying Fields of Grandparents

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.