Skip Navigation

[Resolved] Display a View for a Parent post type

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

Problem:
Customer has a many to many relationship between 2 CPT and a repeatable group within one of them. He created a view for the repeatable group and wants to be able to use a view from the parent of the repeatable group inside the loop. Similar to a parent of a parent scenario since the repeatable groups are considerable child of the CPT they belong to.
Solution:

Upon further review, our 2nd tier support team was able to find a solution.

First, it was necessary to edit the ECD Events view as it needs a post relationship query filter that limits the output to events that belong to some location.

Ordinarily we'd set the filter to show posts related to the post where the View is shown or to the current post in the loop, but that's not going to work here, because the main View is querying ECD Participation repeating groups and not locations.

So the query filter should specify that the parent location will be specified by a shortcode attribute(please check the screenshot bellow).

Then, where the View to output the ECD Events is inserted, we need to pass the ID of the "current" Location via the wpvrelatedto shortcode attribute. And we can get that ID by employing the item attribute to shift the context from the current ECD Participation post to its parent Location, it will look like this:

[wpv-view name="ecd-events-at-location-pin" wpvrelatedto="[wpv-post-id item='@ecd-participation.parent']"]

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

This topic contains 8 replies, has 3 voices.

Last updated by Mateus Getulio 7 months ago.

Assisted by: Mateus Getulio.

Author
Posts
#2691622

I have a Custom Post Type "Location" with an embedded Repeating Group, and Events as child posts to the location.

Now I have a map with a View based on the Repeating Group displaying the location pins. In the popup info, I want to display some data from the Repeating Group, its owning Location and the View that displays the child Events of the Location. But I don't get to enter the owning (parent) Location as the reference for the View?

The "item=" approach similar to field references doesn't work here…
[wpv-view name="ecd-events-at-location-pin" item="@ecd-participation.parent"]

As Repeating groups in post types are treated in a similar way than parent-child relationships, my question could also be: How do I display the View for the "parent" post type?

#2691736

Nigel
Supporter

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

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

Screenshot 2024-04-10 at 08.39.00.png

Hi there

Let me see if I have got this right.

The post type is Location, but the address fields are part of a repeatable field group belonging to the Location post.

So I'm guessing you have a template for a Location post, that has a View to query the repeatable field groups, the output of which generates the map markers (via shortcode).

And the pop-ups for these markers need to reference fields of the parent Location post.

For repeatable field groups the format for the item attribute (to specify a different source than the current post) is "@rfg-slug.parent".

So on my test site I have a repeatable field group "artists", and to output the title of the parent post I would use

[wpv-post-title item="@artists.parent"]

If you use the Fields and Views button to insert a field shortcode and specify the source it will generate the correct format for you (screenshot from my own site).

#2691742
Bildschirmfoto 2024-04-10 um 10.02.26.png

Hi Nigel

Thank you for your reply.

I have a different kind of content in the repeating group, but basically the structural idea is the one you described.

For Fields of the parent posts, yes this is the way to go as you described.

However, what I need to display, is not a Field but a View of the parent post.

Like, for example, a View that lists all (RFG) addresses of the parent Location – let's call it "display sibling posts" (child posts of the same parent posts). Or a View that lists Events (as child post type) to the respective parent Location.

When building this Content Template, the "Fields and Views button" does not allow me to specify the source, as your last sentence promises it. I can generate a shortcode only for the View referring to the current post (which is the RG). There is no parameter to refer the View to the Location (its parent post) instead of the current RG post

#2691924

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello,

I would like to request temporary access (wp-admin and FTP) to your site to take better look at the issue. You will find the needed fields for this below the comment area when you log in to leave your next reply. The information you will enter is private which means only you and I can see and have access to it.

Our Debugging Procedures

I will be checking various settings in the backend to see if the issue can be resolved. Although I won't be making changes that affect the live site, it is still good practice to backup the site before providing us access. In the event that we do need to debug the site further, I will duplicate the site and work in a separate, local development environment to avoid affecting the live site.

Privacy and Security Policy

We have strict policies regarding privacy and access to your information. Please see:
https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/

**IMPORTANT**

- Please make a backup of site files and database before providing us access.
- If you do not see the wp-admin/FTP fields this means your post & website login details will be made PUBLIC. DO NOT post your website details unless you see the required wp-admin/FTP fields. If you do not, please ask me to enable the private box. The private box looks like this: hidden link

If you prefer, instead, I could share with you a sandbox login link where you can replicate this issue for me to take a closer look.

Please, let me know if you need any additional details. Have a nice day.

#2692281

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

I checked this out but so far I couldn't find a fix for it.

I asked my colleagues to have a look at this issue in order to see if there's anything I'm missing.

I'll come back here as soon as one of my colleagues reply back to me (which it shouldn't take long).

Thanks,

#2692491

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hi,

I have escalated this ticket to our 2nd tier of support where our 2nd tier specialists will take a deeper look at this issue and will try to find a solution.

I will get back to you as soon as I get an answer from them.

Best regards,
Mateus

#2692559

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

Thank you for your patience while we check this issue.

Our second-tier support has reviewed the issue, to ensure we provide the most accurate solution, we need some additional details about your end goal.

From our understanding, you have a View which queries ECD Participations and then the markers are added to the output of this View by referring to the parent Location post and its geoaddress custom field.

But as functional child posts, there are likely to be multiple ECD Participations for each location, which means the markers getting added for the same location multiple times.

Could you please confirm if our understanding is correct? Additionally, we would appreciate it if you could clarify the following:

- What specific information do you want to display within each map marker? Please list the details you want to include about the ECD Events.
- Are there any specific conditions or filters you want to apply when displaying these events in the markers?

Understanding these points will allow us to guide you better.

Please let us know and we'll double-check it.
Best regards,
Mateus

#2692562

Hi Mateus

Thank you for getting back to me.

It is correct that there are likely to be multiple ECD Participations for each location over time. BUT as the map pins are filtered by the Year of the ECD participation, there will be only 1 match per location, hence only 1 pin per geoaddress. (unless someone is very stupid and registers for the same day twice, which I try to prevent also by the way I display or hide the link to create ECD participation form. When there is an ECD participation entry of the current year, the link turns into a "you are registered" text)

What I aim to display on the pin info is actually a replica of last year's pin popup info, which is still publicly visible at hidden link . The difference is: Last year I was simply rendering the location post types on the map, because it was the first edition so there was no need to filter among the locations. Locations were created because people participated, so there was no need to filter. Now this year, some of last year's locations may not take part, therefore I need to filter the locations, which is done by using ECD participations with year 2024 as list to be rendered.0

I want to display in the pin popup info:
(last year: "Map Pin" content template hidden link)
- information from the Location post type: Featured image, Post Title, tagline, icons with links to website etc.
- information on the open house day of the current year: Start time and end time > this was directly in the location post last year and has now moved to the ECD Participation repeatable group.
- list of Events at the Location (child post type to location): start time, end time, title

In the "Map Pin 24" content template hidden link
as an adopted version for this year, I managed to render the info on the location and the participation BUT got stuck when it came to getting the view of the location's child events.
This is where I have tried the above-mentioned
[wpv-view name="ecd-events-at-location-pin" item="@ecd-participation.parent"]
that doesn't work out.

#2692867

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

query_relationship.png

Hello there,

Upon further review, our 2nd tier support team was able to find a solution.

First, it was necessary to edit the ECD Events view as it needs a post relationship query filter that limits the output to events that belong to some location.

Ordinarily we'd set the filter to show posts related to the post where the View is shown or to the current post in the loop, but that's not going to work here, because the main View is querying ECD Participation repeating groups and not locations.

So the query filter should specify that the parent location will be specified by a shortcode attribute(please check the screenshot).

Then, where the View to output the ECD Events is inserted, we need to pass the ID of the "current" Location via the wpvrelatedto shortcode attribute. And we can get that ID by employing the item attribute to shift the context from the current ECD Participation post to its parent Location, it will look like this:

[wpv-view name="ecd-events-at-location-pin" wpvrelatedto="[wpv-post-id item='@ecd-participation.parent']"]

I just configured this in your site and it seems to be working properly, can you please test it and confirm that this is what you need to accomplish?

Thank you,
Mateus