Skip Navigation

[Résolu] Display Parent Data On Page of Child Posts using wpv-relationship-filte

This support ticket is created Il y a 6 années. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Ce sujet contient 4 réponses, a 2 voix.

Dernière mise à jour par julieP Il y a 6 années.

Assisté par: Nigel.

Auteur
Publications
#1153054

I have custom posts student and record which are related in a one-to-many relationship. I have a View that queries student posts and provides a link to another page (called Student's Records) which contains a list of all record posts related to the student post. The link format is like this:-

<a href="[wpv-post-url item='1533']?wpv-relationship-filter=[wpv-post-id]">Student Record</a>

My second View (on the page 'Student's Records') queries record posts and uses a Query Filter like this:-
Select posts in a Student Record relationship that are related to the Post with ID set by the URL parameter wpv-relationship-filter.
eg.
lien caché;

This all works fine.

How do I display on the 'Student's Records' page, data from the related student post, i.e. the parent? I thought I could do it by adding this to the View on this page (i.e. my seond one) just before <!-- wpv-loop-start --> like this:-

<p>Records for Student #[wpv-post-id item='student-record.parent']</p>

but nothing is returned. I've checked I'm using the correct relationship slug.

Thanks

#1153114

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

Hi Julie

I think you are just missing an '@' sign in your item attribute, it should be item="@relationship-slug.role".

Can you test that? If you insert fields using the Fields and Views button then use the Post selection tab to specify the source post it should insert the shortcode with the correct attributes.

#1153132

Hi Nigel

Ah yes I see that now! I've used the Fields & Views button and specified the source post (so the @ is now there) but the post ID still isn't displayed. If I remove the attribute (leaving just [wpv-post-id]), the ID of the page the View is on is returned so I guess it has something to do with the filter in the View?

#1153142

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

Sorry, reading the question more closely, I see you are not including this field in the loop (where there would be a current report post that has a student parent) but rather "in limbo", outside of the loop, so that there is no report post to find the student parent of.

Given that you are passing the id of the student via url parameter wpv-relationship-filter, you can re-use that same parameter to provide the id attribute of the wpv-post-title shortcode that should output the title of the student.

Use the wpv-search-term shortcode to populate the id attribute of the wpv-post-title shortcode, like so:

[wpv-post-title id="[wpv-search-term param='wpv-relationship-filter']"]
#1153207

That was just the ticket - thanks Nigel - really appreciate the swift turn round too