Skip Navigation

[Waiting for user feedback] self joining relation Ship

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.

This topic contains 1 reply, has 1 voice.

Last updated by Christopher Amirian 2 days, 1 hour ago.

Assisted by: Christopher Amirian.

Author
Posts
#2835429

I have a custom post type for companies and I need a self joining relation Ship for supplier/dealer relations I create custom post type as intermediate and named it “business”and build 2 relation one to many
1 Supplier relation——— Company - business
2 Dealer relation——— -— Company - business

I create a post form and add page to test the entry
Also I add business table data from company page rather it is supplier or dealer

The problem that I can not at all display the related data in company page rather it is supplier or dealer

Please I need a step by step tutorial to how display the related dealers in the supplier page

Thanks

#2835470

Christopher Amirian
Supporter

Languages: English (English )

Hi,

Welcome to Toolset support. Toolset does not have a Self Joining Feature. Toolset helps you to create many-to-many relationships with intermediary post types, and you can show them on the front end of the website.

Here is how to do so:

1. Make sure you set the Many-to-Many relationships:

- CPT Company
- CPT Business as intermediary
- Relationship Supplier relation: Company ↔ Business
- Relationship Dealer relation: Company ↔ Business

For more information:
https://toolset.com/course-lesson/many-to-many-post-relationships/

2. Create a View that queries the intermediary “business” posts

- Go to Toolset → Views → Add New.
- Content Selection: choose Business (your intermediary CPT).
- This View will be used inside the single Company (supplier) page template.

3. Filter the View by Supplier relation = current Company

- In the View → Query Filter, add Post relationship filter.
- Set it to: Select Business posts that are in Supplier relation with the current post in the loop (Company).
- This makes the View list only “business” records connected to the current supplier.

4. In the View loop, output the related Dealer company

In the Loop Editor, instead of showing Business fields, show the related Company from Dealer relation.

For more information:
https://toolset.com/course-lesson/displaying-related-posts/

5. Insert the View into the Company template (supplier page)

- Edit the Content Template used for single Company posts.
- Insert this View where you want the “Dealers” list to appear (title “Dealers for this supplier”, etc.).
- The template context supplies the “current Company” for the relationship filter.

Thanks.