Skip Navigation

[Resolved] Parent and child views

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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 8 replies, has 2 voices.

Last updated by faustoT 5 years, 11 months ago.

Assisted by: Nigel.

Author
Posts
#1195344

I have a system with Parent and child to show some appointments (child) divided by days (parent)
I divided the appointments by topic (as a tag for appointments) and I would like to recall them in the site posts with a shortcode.
If I create the shortcode directly in the child view, for example [wpv-view id = "12281" wpvargomenti = "uppa"], it works. Obviously if I put the shortcode in the parent view, which divides by days, no.
Is it possible to apply the filter to the parent in some way?
Thank you

Here is the example only with the child hidden link
Here as it comes when I use the parent, but without filter hidden link

#1195420

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi there

I'm having a little trouble understanding what the question is.

You have a parent-child relationship between day posts and appointment posts. Additionally you use tags to categorise the appointment posts with topics.

But I'm not sure what you are trying to display (or what is the problem with what you are displaying).

If you are starting from a day post, you can display related appointments for that day using a View with a Query Filter for the relationship.

When outputting the child appointment posts you can display the topics, and you could display fields from the parent if needed.

If you can explain what you want to display where, I should be able to help, or to clarify what is possible.

#1195432

Sorry, day is a taxonomy of appointment, not a post.
So in parent view i display all the appointment of a day

#1195442

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

OK, so there is just one post type to think about, appointments, which has a "day" taxonomy assigned.

A parent View displays all appointments with a particular day term.

I still don't know what it is that you want to display that you cannot.

#1195504

I would also like to filter for another taxonomy, "argomento" (topic), which should be defined by the shortcode.
In this way I can recall the view directly from an article where I will have all the appointments divided by days concerning a particular "argomento" topic.

#1195901

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Sorry, I'm still struggling to understand exactly what the issue is from your description. (I asked a colleague to read through this thread to see if I was missing something, but they could not understand it either.)

It seems that you have two, nested, Views.

An outer, parent, View, and in the output section of that View you have inserted a second View.

You have a custom post type appointments, a day taxonomy, and a topic taxonomy.

1. Both of these taxonomies are assigned to the appointments post type?
2. What content does the parent View show?
3. What filter should apply to the parent View?
4. What content does the child View show?
5. What filter should apply to the child View?
6. Where is the parent View inserted (a page, a template for a post type)?

I need a clear statement of what you are trying to display where. (I can worry about the technical details of setting it up if I understand what you are trying to do.)

#1195917

I and thanks for your patience.

I try to answer:
1) Yes
2) the parent view (appointment-parent) show days taxonomy, so the loop have [wpv-view name="appointment-child"]
3) there's no filter
4) the child view show post-type appointment
5) i want apply a topic filter, any time i put in a different article
6) i want to place in different articles, one for each topic

For the moment if i only use the child view i can filter adding a shortocde topic. But it's impossible to do so for the parent view because are days and not appointment

Thank you for your help

#1196046

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

OK, now I understand, thank you for clarifying.

You want to be able to pass a value to the Query Filter of a View using a shortcode attribute, but the View is a child View and you need to be able to provide the attribute value where you insert the parent View and use it in the child.

You need the wpv-attribute shortcode for this: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-attribute

Let's say we are going to use "topic" for the shortcode attribute.

Where you insert the parent View, add the topic attribute that you require, e.g.

[wpv-view name="parent-view" topic="test"]

Then in the output section of this parent View where you insert the child View you can pass on the topic attribute again, getting the original value using the wpv-attribute shortcode, like this:

[wpv-view name="child-view" topic="[wpv-attribute name='topic']"]

You could chain together Views passing on the attribute this way as many times as needed.

#1196745

My issue is resolved now. Thank you!