Problem: I have two post types in a one-to-many post relationship, where Department is the parent post type and Service is the child post type. I would like to create a grid showing one parent Department post in each grid cell. Inside each grid cell I would also like to display a list of all the child Services for that parent Department.
Solution: Use nested Views to accomplish this in the legacy Views editor. The general process:
- Create a new View of Departments, choosing to "display all results" in the initial popup
- Use the Loop Wizard to create a Bootstrap grid design or a table-based grid design if your site is incompatible with Bootstrap
- Insert the Post Title or Post Title with Link in the loop for now, we will add the Services list a bit later
- Save the View and insert it in a custom post or page wherever you want to display this directory
- Verify the grid of Departments is displayed as expected and make any grid adjustments needed
- Create a new View of Services, choosing to "display all results" in the initial popup
- Add a Query Filter for post relationships, set for items in the Department / Services relationship as related items of...The current post in the loop
- Use the Loop Wizard to design an unordered list loop and insert the Post Title or Post Title with Link in the loop
- Save the View of Services and return to edit the View of Departments
- In the Loop Editor, place the cursor just after the post title and use the Fields and Views button to insert the View of Services
- Save the View of Departments and check the results on the front-end of the site
Relevant Documentation:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/displaying-related-child-posts/
https://toolset.com/course-lesson/creating-a-view/
https://toolset.com/course-lesson/responsive-columns-and-grids/
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by 4 years, 7 months ago.
Assisted by: Christian Cox.