Skip Navigation

[Resolved] #356 Custom view with filters based on many-to-many relationship custom field

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 3 replies, has 2 voices.

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

Assisted by: Luo Yang.

Author
Posts
#2300467

Hi,

I have a many to many relationship between 2 CPTs, and this relation has a custom checkbox field with 3 possible values.

I then have a view displaying all posts for the first CPT, and would need to add a filter for each one of the 3 possible values.

How should I set this up?

Thanks.

#2300709

Hello,

Toolset Views/Blocks plugins are using WordPress class WP_Query to query posts, you can only filter the result by post fields of same post type, you can not filter the result by fields of another post type.

In you case, I suggest you try these:
Create a post view:
- Query posts of intermediate post type
- Filter by the custom checkbox field
- In view's loop, display the related "first CPT" post information
https://toolset.com/course-lesson/displaying-related-posts/#displaying-one-related-item-parent

#2300801

Thank you.

As the matter a fact, I already have filters based on the current CPT's custom fields.

So I would need to both filter by the current CPT fields, AND the intermediary CPT fields.

How may I set this up?

#2300805

As I mentioned above, there isn't such kind of built-in feature within Toolset plugins, you can add a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
Our developers will evaluate it.

Currently, you might consider to move the custom checkboxes field into post type "first CPT"

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