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:
- 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.
- Create or edit a Content Template used to display events.
- Insert a View block and create a new View.
- Select to display the post type you need (i.e. speakers) and then select the option to display posts related to the current post.
- 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.
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:
Use the following steps to display one related (parent) item:
- Edit the Content Template for displaying the «many» side of the relationship (i.e. the template for «events»).
- You can use any Toolset block to display parent information.
- In the block properties, select the parent from Post Source.
- Select the field you would like to display.
You just added the venue’s details to the Content Template for events!
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:
- Insert or select a block.
- In the right sidebar, expand the Dynamic Sources section.
- Toggle on the option for any of the supported fields in that block.
- Use the dropdowns that appear to select the dynamic source you want this block to display for that field.
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.
Muestra un campo simple
- How to Create Custom Searches and Relationships for Users
- Using Post Reference Field to Set-Up One-to-Many Relationships
- Selecting Parent Posts when Using Forms to Create Child Items
- How to set up Post Relationships in WordPress
- Front-End Forms for Connecting Related Posts
- Show all related topics...
- What Are Post Relationships and How They Work
- Many-to-Many Post Relationships in WordPress