Skip Navigation

[Resolved] Relationship

This support ticket is created 3 years, 5 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 13 replies, has 2 voices.

Last updated by Luo Yang 3 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#2223493
Capture.JPG

Is there a way to add the same Intermediary to 2 different post relationships?

I need to connect Classes, Instructors, Sessions, and Studios so I can show them all in a table.

I am able to see it on my Classes template dashboard page on a table but it is not showing up on the active page hidden link

(the studio info is missing to the right of "art teacher 1" on the Sessions View/table.

#2223807

Hello,

No, there isn't such kind of built-in feature, as a workaround you can setup 4 one-to-many post type relationships, for example:
1) Setup 5 custom post types:
- CPT1
- CPT2
- CPT3
- CPT4
- Intermediary

2) Setup 4 one-to-many post type relationships:
- one-to-many between CPT1 and Intermediary
- one-to-many between CPT2 and Intermediary
- one-to-many between CPT3 and Intermediary
- one-to-many between CPT4 and Intermediary

So when you edit one "Intermediary" post, you can related it with other 4 posts

#2224321

How do you set up an intermediary post type by itself.

I know how to do it when setting up a many-to-many relationship, but how do you set up the intermediary post type on a one-to-one relationship?

Thanks

#2224475

As the workaround I mentioned above, it does not need many-to-many relationship, you can consider "Intermediary" as another post type "CPT5"

#2224537

I figured it out. I related every post type as a 1-to-many with my sessions post type.

My other question now is: can you put if/then into a view? So I have an instructor who teaches several different sessions of 2 different classes. When I pull a view to list the "classes this instructor teaches" on the instructor's page I get a list of the same class over and over. So even though he teaches 3 sessions of Class A, and 3 sessions of Class B, I only want to show a view listing Class A and Class B one time each. Basically it needs to say "if this class is listed more than once for this instructor then only list it once".

#2224551

And the way I have the post relationship set up is one-to-many/instructor-to-session. So the instructor is related to the session and is only related to the Class A and Class B b/c of a field in the Session. So that is why my view is pulling the Class A and B 3 times each.

#2224555

In the single "instructor", you can display a post view:
- Query "sessions" post
- Filter by post type relationship between "instructor" and "sessions"
- In view's loop, display the related Classes, Instructors and Studios post information

More help:
https://toolset.com/course-lesson/displaying-related-posts/

#2225233

That sounds exactly like what I did but the view is still showing ALL the sessions related to the class.
I want it to show just the top level Class Name, which it is, but it is showing the same class name multiple times because that class has many sessions.
I want to show only the class.

#2226453

That is expected result, since one class has multiple related sessions, so it will show same class name multiple times.

You might consider this:
1) setup another many-to-many relationship between Instructors and Classes.
2) In the single Instructors post, display a post view:
- Query Classes posts
- Filter by post type relationship of step 1)

#2226971
view query classes for instructors to classes relationship.JPG
view trying to select class but it only lets me select instructor.JPG

This is not working. I think something is wrong with the views plugin because it is not pulling the information that it is supposed to pull.

I did your steps above but no matter what options I select for the view query I'm only able to select the "instructor" as the source instead of the "class". See screen shots.

This happens even when I use an incognito window with Chrome and it also happens no matter what post relationship I'm using. (I created a many to many relationship between Classes and Instructors and another one between Instructors and Classes just to check if there was a difference.

I'm having this same issue in other views as well where it doesn't seem to give me the correct option in the "Post source" field.

Am I doing something wrong here?

#2227365

It should be able to work, please provide a test site with the same problem, fill below private message box with login details, also point out the problem page URL, I can setup a demo for you

#2229225

The relationships are not connecting. So I update an instructor and connect her with a class and a studio. I go check that class and the instructor is not connected!

#2229563

Thanks for the details, I am checking it in your website, will update here if find anything

#2229587
connections.jpg

Q1) You don't need to setup two duplicated many-to-many relationships:
- Instructors to Studios (Many)
- Studios to Instructors (Many)
You just need one of them, I have done below modifications in your website:
1) Deactivate relationship "Studios to Instructors (Many)":
Edit relationship "Studios to Instructors (Many)"
hidden link
Change the post status as "Draft"

2) Edit the content template "Template for Studios":
hidden link
Find and select view block "Studio Page: Instructors who work at this studio", in section "Content Selection", change the "Query Filters" as below:
Select posts in a Instructors to Studios (Many) relationship that are related to the Post where this View is shown

Test it in frontend:
hidden link
It works fine, I can see the correct results in section "Instructors who work at this studio"

Q2) I go check that class and the instructor is not connected!
Where and how can I see the problem you mentioned above?
I assume we are talking about single "Session" post, for example:
hidden link
I can see this "Session" post is connected to other posts, see my screenshot connections.JPG