Skip Navigation

[Resolved] Display a parent child related posts in a tree-like structure

This support ticket is created 2 years, 3 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 22 replies, has 2 voices.

Last updated by Franco Calcagni 2 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#2434399

We need to display in the sidebar a list of parent/child elements in a tree-like shape, We already created the parent-child post types but we don't know how to show the parent only once with all childs under each parent, for example

STUDIO 01
- Architect 01
- Architect 02
- Architect 03

STUDIO 02
- Architect 02
- Architect 03

Where STUDIO is the parent element and ARCHITECTS are the child (please note that an architect can belong to more than one studio).

We just need to display these elements but as you see in the following link we now have the STUDIO that repeats for every ARCHITECT
hidden link

Thanks for any help.

Franco

#2434787

Hello,

You can try with a nested views, for example:
1) Parent post view:
- Query "STUDIO" posts
- In view's loop, display "STUDIO" post information + below child post view

2) Child post view:
- Query "ARCHITECTS" posts
- Filter by post type relationship between "STUDIO" and "ARCHITECTS"
- In view's loop, display "ARCHITECTS" post information

#2434865

Hi Luo,
Is it possible for you to enter the website and build the views for me?
Please let me know so I can grant you the access.

Thanks
Franco

#2434867

Yes, please try these:
1) Backup your website
2) provide your website credentials in below private message box

#2434917

Hi Luo,
please note that both STUDIO and ARCHITECTS to be displayed shall be ONLY the ones related to the specific SCHEDA and NOT all architects of that studio.

Thanks.

Franco

#2434927

I can login into your website, but it is not an admin account, please check it, make sure it is an administrator account.

And please elaborate the question with more details:

both STUDIO and ARCHITECTS to be displayed shall be ONLY the ones related to the specific SCHEDA and NOT all architects of that studio.

You can use the "SCHEDA" post as example:
hidden link
Which "ARCHITECTS" and "STUDIO" do you want to display in the nested view? is there any post type relationships between them?

#2435055

Hi,
Now you have admin profile.
The data we need to display (STUDIO and ARCHITECT) are related to the specific SCHEDA.
For example a SCHEDA is a building that is projected by two STUDIOS and for each STUDIO only some ARCHITECTS of they STUDIO worked on the project.
We created some relationships between studios, architects and scheda.
What we need to display is the list of STUDIOS and for each element we need to indent the ARCHITECTS only related to that SCHEDA.
In the first version of the website, some of your colleagues weee able to recreate that list of items but after a new release of Toolset the views were not anymore able to display the content in the right way.
Please note that in case of multiple ARCHITECTS related to the same STUDIO, the name of the STUDIO shall be displayed once as a parent element and under it the list of ARCHITECTS.

Please let me know if you need more info.

Franco

#2435529

Your website isn't in English, and there are lots of post type relationships in it, it is hard to locate the responding relationships.

I can login into your website, I assume we are talking about this case:
Three post types
- Schede
- Studi
- Architetti

How do you setup post types relationships between above post type?
Please point out those relationships URLs, thanks

#2435715
relation.jpg

Hi Luo,
yes you are correct, the SCHEDE is the main post type referred to a building, the STUDIO is the post type referred to the company that made the project and ARCHITETTI are the people involved in the project.
There are 2 main cases:
1) the ARCHITETTI are childs to a STUDIO which is a child of SCHEDA
2) the ARCHITETTI are direct child to a SCHEDA for some specific projects

Please consider as I said before that both STUDIO and ARCHITETTI to be displayed are the only related to the specific SCHEDA and are mentioned in the following relationship (see screenshot)

scheda_scheda-studio-arch

but please feel free to create a different relationship if our direction was wrong

you can do a copy of the content template named
"Template for schede"

and work on that.

Please let me know if you have further info

Thanks

Franco

#2436431

I assume we are talking about those two post type relationships:
1) Schede Studi:
hidden link
2) Studi Architetti:
hidden link

You are going to:
In single "Scheda" post, display related "Architetti" posts in tree like struture.

I have done below modifications in your website:
1) Parent post view:
hidden link
- Query Studi posts
- Filter by:
Select posts in a Schede Studi relationship that are related to the Post where this View is shown.
- In Views loop, display Studi post information + below child post view

2) Child post view:
hidden link
- Query Architetti posts
- Filter by:
Select posts in a Studi Architetti relationship that are a related to the current post in the loop.
- In view's loop, display Architetti post information

3) Edit content template "Template for Schede":
At the bottom, add a view block, choose above parent post view:

Test it in frontend:
hidden link

It works fine, please check if it is what you want, thanks

#2436541

Hi Luo.
The post you listed works fine but all other posts of the SCHEDE have “no items found” alert.
You mean that we need to populate SCHEDE with the data structure you indicated?
Please let me know what are the activities we need to do so to have the correct result on all SCHEDE posts.

Anyway as soon as I can work on my laptop later today I will have a detailed look at what you did and listed above.
For the time being. Prefer to leave the ticket open in case the result is not achieved.

Thanks

Franco

#2437899

Yes, in your case, I suggest you use those two post types relationship to connect those three post types.

I have marked this thread as "Waiting for feedback" status, you can update here if you still need assistance for it.

#2440025

Please leave the ticket open I will get back to you ASAP

thanks

Franco

#2440069

I have marked this ticket as "Waiting for feedback" status, you can update here if you still need assistance for it.

#2440301

Hi Luo,
I had a look at the changes you made in the template "Template for Schede". Unfortunately the result is not what expected for two reasons:

1) In the following post
hidden link
the ARCHITECTS related to the specific SCHEDA are 2 (Filippo Pagliani and Michele Rossi) if you look at the specific SCHEDA post type you see that relationship in the box "scheda_scheda-studio-arch".
But the result on the frontend is a list of 3 ARCHITECTS /Zaha Hadid is added) because the view lists ALL architects of that STUDIO and NOT only the ARCHITECTS that are related for that STUDIO in that specific SCHEDA (just the first 2).
So I presume that the filter that shows only the results included in the specific post is not working.

2) In the following post
hidden link (see in the backend editor of that post type)
the relationships are
- BG&K Associati (studio)
----- Maurice Kanah (architect)
- Gla - Genius Loci Architettura (studio)
----- Stefano Boninsegna (architect)

If you need to rebuild the port relationships between those data (SCHEDA / STUDIO / ARCHITECT) please feel free to create additional relationships from scratch and let us know if we shall do some changes to the content structure.

Please set me know if explained the issue in a clear way.

Thanks

Franco