Skip Navigation

[Resolved] Understanding with Relationships

This support ticket is created 2 years, 2 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
- 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 3 voices.

Last updated by Luo Yang 2 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#2486645

I am trying to work on relationships. I have few queries regarding the same,
When I am creating Many to many relationships in and while creating a template for the Custom Post type in the Field Source, I am not able to select the other CPT while this is not the case when I am creating One to many relationships.

#2486745

Nigel
Supporter

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

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

Hi there

If you are editing the template for the many-part of a one-to-many relationship you can choose to show fields from the one-part of the relationship directly (e.g. to show fields from a parent post in the child template), and you can do this because there is only one post that you are referring to.

Whenever you want to show a field from the many-part of the relationship (e.g. you want to show a field from child posts, or from posts connected via a many-to-many relationship), the problem is that there are many possible posts the field value could come from, not just one.

In that case you must display such field values indirectly, using a View, which will loop over the many posts (e.g. all of the child posts) and output the field for each one.

Please check this page which gives more details: https://toolset.com/course-lesson/displaying-related-posts/

#2486825

Thanks for the reply, in that case when I am creating Views then I am not able to make a view for one-to-many post where I can list all related post for single related post

#2487373

Hello,
For the question:

I am not able to make a view for one-to-many post where I can list all related post for single related post

It is not clear, are we talking about one-to-many or many-to-many relationship.

If it is many-to-many relationship, you need to create a post view:
- Query posts of related post type
- Filter by the many-to-many relationship
- In view's loop, display the related post information

See our document:
https://toolset.com/course-lesson/many-to-many-post-relationships/#displaying-related-posts
section "Displaying Related Posts"

#2487377

I am talking about one-to-many relationship if the same is possible with one-to-many relationship as described by you for many-to-many relationship.

#2487381

For one-to-many relationship, it works just like parent/child relationship:
- In single parent post, you need to setup a post view to display child post information, see our document:
https://toolset.com/course-lesson/displaying-related-posts/#displaying-many-related-items
section "Displaying many related items"
- In single child post, you can display it's parent post information directly, see above document:
https://toolset.com/course-lesson/displaying-related-posts/#displaying-one-related-item-parent
section "Displaying one related item"

Hope it is clear