Skip Navigation

[Resolved] Trying to show childs fields in a parent content template

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

Problem: I need to show all the workers belong a Job (parent) in a list in the parent content template.

Solution:
One way to do this is to nest two Views together.
1. Create a View of Jobparts, filtered by Post Relationship where the parent Job is set by the current post
2. In the Loop editor of that View, click "Loop Wizard" to design an unformatted loop. For now, insert the Post Title shortcode.
3. Place this View on the single Job post page, and you should see a jumbled up list of Jobparts. That's fine for now.
4. Create a View of Workers, filtered by Post Relationship, where the parent Jobpart is set by the current post in the Loop
5. In the Loop Output editor, build your list of Workers however you would like to format them
6. Edit the View of Jobparts and delete the wpv-post-title shortcode in the Loop Editor. Replace it with the shortcode to display the View of Workers.

Relevant Documentation:
https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/

This support ticket is created 5 years, 11 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.

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 David 5 years, 10 months ago.

Assisted by: Christian Cox.

Author
Posts
#1193912
Content Template - Parent post type.png

Hello there! I have an issue displaying child fields in a parent content template.
I explain to you then:

I have 3 CPT´s:
· Job (parent)
·jobpart (child)
· and workers (jobpart´s child).

For example, I have a job (reforming a house) with two jobparts (paint the walls and change main pipe) and finally I have three workers: Painter1, Painter2 and plumber1.

I´m designing templates for Job post type (parent) as you can see in attachment (please check the image on it)

Well, I need to show all the workers belong a Job (parent) in a list in the parent content template. Is it possible to do it? I´m trying but I can´t.

I´m trying making a view [wpv-view name="workers"] but isn´t working.

I don´t know if I need to create a "Job-Workers" relationship in order to show all the workers belong a job or I have to use another shortcode to do it.

Could you help me, please?

#1193934

Well, I need to show all the workers belong a Job (parent) in a list in the parent content template. Is it possible to do it? I´m trying but I can´t.
Hi, one way to do this is to nest two Views together.
1. Create a View of Jobparts, filtered by Post Relationship where the parent Job is set by the current post
2. In the Loop editor of that View, click "Loop Wizard" to design an unformatted loop. For now, insert the Post Title shortcode.
3. Place this View on the single Job post page, and you should see a jumbled up list of Jobparts. That's fine for now.
4. Create a View of Workers, filtered by Post Relationship, where the parent Jobpart is set by the current post in the Loop
5. In the Loop Output editor, build your list of Workers however you would like to format them
6. Edit the View of Jobparts and delete the wpv-post-title shortcode in the Loop Editor. Replace it with the shortcode to display the View of Workers.

This technique is called nesting Views, and is discussed in more detail here: https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/

You may need to adjust the markup or CSS to get it to look exactly like you want. Let me know if you have questions about this approach.

#1203738

My issue is resolved now. Thank you!