Skip Navigation

[Resolved] filtering on an extra field of a relationship

This support ticket is created 3 years, 9 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/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by inekeH 3 years, 9 months ago.

Assisted by: Waqar.

Author
Posts
#1716355

Hello,

I have created a many-to-many relationship between two post types in order to connect courses (in this case woocommerce products) and teachers.
To specify the relationship I added an extra field to the relationship: a checkbox in order to specify this teacher as the "main" teacher for the course. This is the only teacher I want to show in the product overview page. So I'm trying to filter a view to show only those related posts with a certain value of an extra relationship field.
I cannot add this field to the teacher itself because in another course this teachers might not be the main teacher.

I found on the forum you need no make the intermediary posts visible in the admin. So I did.

But now I'm stuck. The filter won't work.
I tried various options, but the teacher won't show. I also tried to use conditional output, but that won't work either.

I'm using two views, one container view to count the number of teachers and add a <span> in case there is more than one (which is working fine) and another one to show the teacher.

Could you please take a look at what I'm doing wrong?
I could send you login credentials.

You can see an example at hidden link

Is it necessary to make two different relationships, one for the main teacher and one for the remaining teachers? Would that help?
My intuition tells me it would be more elegant to be able to filter (or sort and limit the number of items shown, but I cannot get it to work.

Best regards,
Ineke

#1716913

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

From your message, I understand that the checkbox field for setting the "Main" teacher is registered with the intermediary post.

If that is correct, the filter for this field would also only work in the view that is set to query intermediary posts and not the teachers or courses.

In other words, the required logic for the view would be "to bring all intermediary posts related to the current course, where the main checkbox field is checked".
( and if the data has been entered correctly, that should only return one intermediary post )

Once you'll have the correct intermediary post, you can show any information from the relevant teacher or course post too.

I hope this helps and in case you still face any challenge, you're welcome to share temporary admin login details.

Note: Your next reply will be private and though no changes will be made on your website, please make a complete backup copy, before sharing the access details.

regards,
Waqar

#1717007

Hi Waqar,
Thank you for reaching out. Your reply made me think of the fact that the intermediary post in itself, of course, does not carry the information about the teachers. I missed out on the item="@cursus-docent.child" part in the content template.
It seems to work now, so I think I can figure it out now. Thank you!
Best,
Ineke

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