Skip Navigation

Displaying Related Posts in WordPress

Toolset allows you to easily display related posts on the front-end. You can display one related parent item, many related child items, or the information from the intermediary post type.

There are two ways to display related posts:

  • In one-to-many relationships, display fields that belong to the “one” side.
  • Display a list of the “many” related posts in both one-to-many and many-to-many relationships.

When we say “one”, we mean items that are connected as “one-to-many” and are on the “one” side.

For example, a venue can have many events, but each event belongs to only one venue. When displaying a single event, you can display information about its venue.

  1. Edit the Content Template for displaying the “many” side of the relationship (i.e. the template for “events”).
  2. You can use any Toolset block to display parent information.
  3. In the block properties, select the parent from Post Source.
  4. Select the field you would like to display.

You just added the venue’s details to the Content Template for events!

Selecting to display information from a parent post

In Toolset, every time you need to display a list of items, you should use a View. This includes displaying “many” related items. You should use this in two cases:

  • When displaying a list of items (the “many” side) in a one-to-many relationship
  • When displaying related items in a many-to-many relationship

In our example, events have many speakers, so we’ll use a View to display them.

  1. Create or edit a Content Template used to display events.
  2. Insert a View block and create a new View.
  3. Select to display the post type you need (i.e. speakers) and then select the option to display posts related to the current post.
  4. Use blocks to design the output for your View. Because the View is already set to display related posts you don’t need to select the relationship in blocks you use to display dynamic content.
Selecting related posts to display with a View
Displaying dynamic fields inside the View that lists related posts

When you are designing a View for related content, in a many-to-many relationship, you may also want to display fields that belong to the relationship.

To do this, add Toolset blocks to the View and use the Post Source to select the relationship (only available if you’ve added custom fields to the relationship in question). Then, choose the field to display.

Main Toolset Block Used in this Lesson

Display a single field