Skip Navigation

[Resolved] View query filter: two relationships

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

Last updated by RaulS6474 4 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#1563185

Hi,
I have two kind of ads to show on a view: profesional services and events.
Each ad is related to a third post type: postal code.
There are 2 one-to-many relationships: postalcode-service / postalcode-event /

I've created a view selecting both post types on content selection.

The idea is to have a unique view mixing both types, and be able to make a first parent filter to choose what kind of ads you want to see. Once it's selected that filter it should open other options for that post type.

While creating Query Filter in view, I am only able to select one relationship.

Is this posible? I am working on the good direction?

Thanks!

#1563429

Hello,

It is expected result, one post view can only add one post type relationship filter.

But it is possible with custom PHP codes, for example you can use filter hook "wpv_filter_query" to trigger a custom PHP function
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

In this PHP function add other post type relationship filter, see our document:
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/how-to-migrate-your-site-to-new-post-relationships/#advanced-example

See similar thread here:
https://toolset.com/forums/topic/search-filter-with-two-post-relation-ships/#post-1216763

#1565737

My issue is resolved now. Thank you!