Skip Navigation

[Resolved] Create a grid of parent posts, with lists child posts for each parent

This thread is resolved. Here is a description of the problem and solution.

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 support ticket is created 4 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 stewartE 4 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#1705147
grid.PNG

I want to create a grid of parent posts with their child posts underneath. Following the instructions, I seem to be able to create a page with 1 parent post and its children in not all. Note I am using Views not Blocks

To explain I have a Custom Post Type called Departments and another Custom Post type called Services. I have related those 2 in a one to many relationships. A Department can have many Services. What I want to do is create a kind of directory layout in a grid. Please see the attached screenshot to see what I mean. Any help would be much appreciated!

#1705419

Hi, yes you should be able to accomplish something like this with two Views nested together. Given that you are using legacy Views and not the Block Editor builder for Views, here's how I would do it:
- 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

Now you have a nested child post View inside a parent post View, with a Query Filter set up so that the nested View of child Services shows only the Services of its parent Department. Let me know if you get stuck or need additional information.

#1706531

My issue is resolved now. Thank you!