Skip Navigation

[Resolved] View of related post to be filtered on checkbox field on intermediary post type

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a many-to-many post relationship set up with a custom field applied to the intermediary post. On the single post page for one of the post types, I would like to display all the related posts, filtered by the custom field on the intermediary posts.

Solution: Create a View of the intermediary post type, filtered by the custom field and also by post relationship, where the post is related to the current post or page. Then in the Loop, select the related post in the Post Selection tab when you insert any Fields or Views shortcodes.

This support ticket is created 4 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Tim Elliott 4 years, 11 months ago.

Assisted by: Christian Cox.

Author
Posts
#1239394

Hi support team

I have a many to many relationship as follows:
Events >> Events Event People >> Event Speakers
"Events Event People" has a custom checkbox field "Event People Role" with 2 options (advisor, speaker)

In the Events Content Template I want to show 2 views:
All Event Speakers that have "Event People Role" set to advisor
All Event Speakers that have "Event People Role" set to speaker

For the Query Filter I have one filter that uses:
Select posts in a Events Event People relationship that are related to the Post where this View is shown

This works to display all related Events Speakers, but I'm struggling to set up the filter to limit this by the "Event People Role".

I've tried -
Select items with field: Event People Role is a string equal to advisor
But this doesn't work (it give no results) - I guess it's trying to find that field value on the "Event Speakers" post rather than the intermediary post.

Is there some way to filter on this field or do I have to include all of them, and then use a conditional to filter by the intermediary field inside the loop?

Thanks

#1239491

Actually, I can't use a conditional to filter by intermediary field as this will mess up the loop wrap.

#1239506
1.png
2.png
3.png

Hi, in general it's best to take this approach:
- Create a View of the intermediary post type Events Event People.
- Add a post relationship Query Filter like the one you described: Select posts in a Events Event People relationship that are related to the Post where this View is shown. You cannot currently filter a View by related post fields, so the Content Selection must be the same as the post with the checkbox field.
- Add the checkbox custom field filter to filter only advisors.
- In the Loop, you want to display information about the parent Speaker. When you build the loop using the Loop Wizard, you can use the "Edit" button next to each field to select a related post. See 1.png and 2.png.
- If you do not use the Loop Wizard, you can use the "post selection" tab when inserting Fields and Views to select a related post. See 3.png and 2.png.
- Once this View is working as expected, you can duplicate the View and change the checkbox filter.

#1239527

Thanks Christian. That worked.

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