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.

Duration

There are two ways to display related posts:

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

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.

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.

Here’s a short video that explains the steps:

Duration

Use the following steps to display one related (parent) item:

  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

Toolset comes with a big collection of blocks to display related dynamic sources (custom fields, WordPress fields, and taxonomies). However, you can also display related Dynamic Sources using WordPress core blocks and popular block plugins.

Use the following steps to display a Dynamic Source in any supported block:

  1. Insert or select a block.
  2. In the right sidebar, expand the Dynamic Sources section.
  3. Toggle on the option for any of the supported fields in that block.
  4. Use the dropdowns that appear to select the dynamic source you want this block to display for that field.

Display Dynamic Sources inside all text blocks

Toolset allows you to display Dynamic Sources, like custom fields, inside any text blocks like headings, buttons, and more. This includes WordPress core blocks, Toolset blocks, and popular block plugins.

To display any Dynamic Source inline, insert or select a block with a text input and look for the Inline Fields button. Dropdown menus will appear, allowing you to select a Dynamic Source.

For more information, check out the lesson about displaying Inline Fields.

Main Toolset Block Used in this Lesson

Zeigen Sie ein Einzelfeld an

Updated
Januar 26, 2021