Skip Navigation

[Resolved] Display grand-parent relationship

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

Problem: I would like to display information about a post, its parent, its grandparent, and its great grandparent.

Solution: Use nested Content Templates to access grandparent information.

Relevant Documentation:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/displaying-fields-of-grandparents/

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)

Author
Posts
#1162797
Funkman733   incontrAmici.png

I am trying to: see this tread https://toolset.com/forums/topic/drop-down-menus-for-countries-and-cities-in-dependency/

Link to a page where the issue can be seen: hidden link

I expected to see: Sono di [City, parent], in Provincia di [Provincia, grandparent], Regione [Regione, grandgrandparent] ([Paese, grandgrandgrandparent])

Instead, I got:
Hi, I'm trying to display the grandparents, but I don't why, I cannot display nothing...
So I need to display that:
"Sono di [City, parent], in Provincia di [Provincia, grandparent], Regione [Regione, grandgrandparent] ([Paese, grandgrandgrandparent])."

I have created a Content Model for every grand-parent.

I have created a View, where I have inserted into the loop all I need

	
[wpv-layout-start]
    [wpv-items-found]
    <!-- wpv-loop-start -->
        <wpv-loop>        
        Sono di [wpv-post-link item='@citta-profilo.parent'], [wpv-post-body item="@provincia-citta.parent" view_template="mostra-provincia"], [wpv-post-body item="@regione-provincia.parent" view_template="mostra-regione"] ([wpv-post-body item="@paese-regione.parent" view_template="mostra-stato"])            
        </wpv-loop>
    <!-- wpv-loop-end -->
    [/wpv-items-found]
    [wpv-no-items-found]
        <strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
    [/wpv-no-items-found]
[wpv-layout-end]

In the template I have inserted the view shortcode and I have that (see the attached image)

what is the issue?

#1163186

Hi, the problem here is that these Content Templates should be nested inside each other. Mostra Stato should be nested inside Mostra Regione. Mostra Regione should be nested inside Mostra Provincia, and so on. You probably should create one more Content Template, Mostra Citta. Nest the Mostra Provincia template inside Mostra Citta, then add the Mostra Citta template to the View loop like this:

<wpv-loop>        
        Sono di [wpv-post-link item='@citta-profilo.parent'], [wpv-post-body item='@citta-profilo.parent' view_template="mostra-citta"]           
</wpv-loop>
#1163977

Thanks for reply.
So, I'm trying to do that but something went wrong...
1- I have created a Content Model called "Mostra Stato"

[wpv-post-link item="@paese-regione.parent"]

2- I have created a Content Model "Mostra Regione"

<a href="[wpv-post-url item="@regione-provincia.parent"]">Regione [wpv-post-title item="@regione-provincia.parent"]</a> ([wpv-post-body item="@paese-regione.parent" view_template="mostra-stato"])

3- I have created a Content Model called "Mostra Provincia"

<a href="[wpv-post-url item="@provincia-citta.parent"]">Provincia di [wpv-post-title item="@provincia-citta.parent"]</a>, [wpv-post-body item="@regione-provincia.parent" view_template="mostra-regione"]

4- I have created a View called "Sono di"

[wpv-layout-start]
	[wpv-items-found]
	<!-- wpv-loop-start -->
		<wpv-loop>		
        Sono di [wpv-post-link item='@citta-profilo.parent'], [wpv-post-body item="@provincia-citta.parent" view_template="mostra-provincia"]           
		</wpv-loop>
	<!-- wpv-loop-end -->
	[/wpv-items-found]
	[wpv-no-items-found]
		<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
	[/wpv-no-items-found]
[wpv-layout-end]

So, what is wrong is because I have used the Content Model and instead to display correctly it need to use annidated View for every relationship?
But why cannot I display not even only the City name?

#1164049

You don't need a View for each relationship, you need a Content Template for each relationship.

[wpv-post-link item='@citta-profilo.parent'], [wpv-post-body item="@provincia-citta.parent" view_template="mostra-provincia"] 

This code is from a View of Profilo posts. The problem is that @provincia-citta.parent doesn't work in the context of Profilo posts. It only works in the context of a Citta post. That's why you must put this code in a Content Template, and then replace the Provincia template with the Citta template. In the View:

Sono di [wpv-post-link item='@citta-profilo.parent'], [wpv-post-body item="@citta-profilo.parent" view_template="mostra-citta"] 

Then nest your Provincia template in the Citta template.

#1164069

Hi,
but what I need to write in the Content Template about this

[wpv-post-body item="@citta-profilo.parent" view_template="mostra-citta"]

?

If in the loop I put only this code

Sono di [wpv-post-link item='@citta-profilo.parent']

, in the Profilo post in front-end I can display only "Sono di ". If I put the code outside of the loop I can display "Sono di [My Città name]"

And so, I can display only the Città partent and the Provincia grand-parent? I cannot display the Regione grand-grand-parent and the Paese grand-grand-grand-parent?

Sorry, but I think my mind have a limit now, because I don't understanding the local function to obtain what I need... sigh!

#1164826

Don't put this code in the Loop:

Sono di [wpv-post-link item='@citta-profilo.parent']

Put the Citta Content Template in the Loop:

[wpv-post-body view_template="mostra-citta" item="@citta-profilo.parent"]

Then put the Sono di... code in the Citta Content Template:

Sono di [wpv-post-link], [wpv-post-body item="@provincia-citta.parent"]

If it's not working, I'll be glad to log in and help set this up. Please provide login credentials in the private reply fields here.

#1164978

Check now, I have updated the templates and links.

#1164993

My issue is resolved now. Thank you!