Saltar navegación

[Resuelto] Is it possible to get the relation of a relation?

This support ticket is created hace 3 años, 2 meses. 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: Africa/Casablanca (GMT+01:00)

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por martinP-14 hace 3 años, 2 meses.

Asistido por: Jamal.

Autor
Mensajes
#2196893

Hi, I wonder if I can grab Infos of a relation of a relation in a view… and if so, how…

Example. I have a data model with a CPT „Shootings“ to which one or more CPT “Brands” are related. Each brand can be connected to one or more CPT “Sales Agents”.

Now I want to create a template to show a Shooting. At the end of the page I want to show logos of the Brand(a) which are in the shooting.

And in a widget I want to show the Sales Agents which are related to a Brand.

Any idea if this is possible and how?

#2197465

Hello and thank you for contacting Toolset support.

That's totally possible, but you will need to use intermediate content templates or views. For 1-to-1 and 1-to-many relationships, you can get the child or the parent posts from the 1-to-1 content template directly through a shortcode by passing the correct item attribute. Read more about it here https://toolset.com/documentation/programmer-reference/views/views-shortcodes/item-attribute/
If you want to get the parent post in a 1-to-many relationship, you can do the same.

But for the related posts in a Many-to-many relationship or the child posts of a 1-to-many relationship, you will need a view.

When you are looking for a list of posts, you will always use a view. When you are looking for one post you can use a content template and the item attribute.

Now that you want to look for related posts of related posts, first, you will need to get the related posts, then through them with the same method, you will get their related posts.

I hope this makes sense? Let me know if you have any further questions, and let me know the nature of these relationships(1-to-1, 1-to-many, many-to-many)

#2201377

My issue is resolved now. Thank you!