Skip Navigation

[Resolved] Many-to-Many relationship want to call field from other CPT

This support ticket is created 6 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.

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 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Author
Posts
#538502

I have set up a many-to-many relationship (Sports Providers and Camps) with "Camp Appearance" as the intermediate CPT.
It works to some extend but now I'd like to call a field from "Sports Providers" to publish it on the Camp page.
I want to publish the contact details of the sports providers organising the camp. (Often I'll have 2 or more sports providers working on one camp.)
In the intermediary (Camp Appearances), I haven't named any post fields. (Should I do this?)

What do I need to do?

[types field='twitter' target='_blank' id='$camp-appearance'] doesn't work as I haven't named that field and [types field='twitter' target='_blank' id='$sports-provider'] doesn't give any results either.

Thanks!

#538683

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pierre,

Thank you for contacting our support forum.

Are the fields that you are trying to display the direct parent of the child cpt ? Is there an intermediary CPT between them ?

Please let me know.
Thanks,
Shane

#538686

Hi Shane,

I'm trying to display the fields of a CPT which are related through another child post.
The relations I have are based on your tutorial on Many-to-Many relations.
"Camp Appearance" (intermediary) is a child to Camp & Sports Provider.
In both parents page, I'm trying to have information about the other parent.
E.g. in the Sports Provider page, I want to have the list of camps for each sports provider and under camps, I need to have the contact details of the Sports Provider.
I tried with a view but doesn't work. (at least how I've done it)
Camp Appearance is purely there to create a relationship (no info in it).

#538737

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pierre,

This one may not be possible based on how our many to many relationships work because A child can display its parent information but if you are trying to display information on its sports provider then a view will be needed.

Lets try this.

We create a view to display the children of the current parent "Camp" on that view you will only add this field.
[types field='twitter' target='_blank' id='$sports-provider']

Since the view will be listing out the "Camp Appearances" that are children of the Camp and since the Sports Providers are also parents of the Camp Appearances then this setup should work.

Please try this and let me know if it helps.
Thanks,
Shane

#538889

Hi,

This is what I had done but it returns all the results, this is e.g. all the phone numbers of every sports provider related to a camp - not just the one I'm looking for.
Similar when I want to publish the organisers of a camp, all sports providers who organise " a" camp are published.

In the Post Relationship (from within the Camp page), I selected the 2 camp providers working on a particular camp, but still I get all 4 sports providers (2 on each camp I have created so far) when publishing the view cell.
Do I need to add a query? I couldn't find anything that would work there.

Here's what I done:
Create View Cell in Camp
No query
Filter Editor: didn't do anything to it
Loop Output Editor: as I want to have the names of the sports providers with a link to their page, [wpv-post-link id="$sports-provider"]

Am I doing anything wrong or do you need more info?

Thanks!

#538931

Hi Shane,

I found my mistake, I create the right query (I had played with it but not correctly!)
Thanks for your help and directing me in the right place.

This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.