Skip Navigation

[Resolved] How to build a parametric search filtering posts with two or more parents types?

This support ticket is created 7 years, 7 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 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 9:00 – 18:00 -
- - - - - - -

Supporter timezone: Europe/Madrid (GMT+02:00)

This topic contains 6 replies, has 4 voices.

Last updated by Beda 5 years, 6 months ago.

Assisted by: Juan.

Author
Posts
#435716

Hi guys,

I've setup a many-to-many relationship that links Projects / Products / Applications types through a common child type named "sublink".

The scenario is:

I need to build a list of Projects filtering them by Product used in it or by the Application achieved.

I've made a View selecting "sublinks" to be listed.
Then I go to the filters section and setup a new filter picking the "Post relationship" option and then setting the "products" tree.

Everything's fine.

I then tried to add another filter just like this that would have had the "applications" tree selected but when I click the "add filter" button there were no "Post relationship" anymore to be selected.

Is there a way to add a second filter or would you please suggest a workaround for this?

Thanks
Carlo

#435973

Dear Carlo,

You are right, you can add only one "Post relationship" filter with Views UI, if you agree, we can take it as a feature request.

Currently, you can try add the filters with Views filter hook "wpv_filter_query"
Filters the main Query in a View displaying Posts
https://toolset.com/documentation/user-guides/views-filters/wpv_filter_query/

#435978

Hi Luo,

of course I'd like you to add this request as a feature request.
I think it would be really appreciated.

Thanks
Best regards
carlo

#436733

Juan
Supporter

Timezone: Europe/Madrid (GMT+02:00)

Hi Carlo

This is Juan, lead Views developer here. Thanks for the feedback.

Mmmm I think you have something here. Most of our query filters default to only one instance per filter. For example, when you filter by a custom field, you can set the filter so it listens to several values, but you can nt have two different filters listening to the same custom field. It happens the same for filters by taxonomies, or by post author, etc. The only query filter that we dsigned from the ground up to suport multiple instances is the filter b post date.

Now, you have a situation that is not so weird: a post type that has two parents. In this scenario, it makes all the sense in the world to be able to filter by a value on each parent post type. Unfortunately, we did not see this in advance and both the way we store our data and our GUI do not support that - yet.

I am taking a note to review and maybe refactor/rewrite this element, so we can support filtering by more than one relationship tree at the same time. It seems like an easy task, but let's see how it goes before claiming that this can be done in short time. I can not make promises or set estimations of timings, but I can tell you that this is something I would like to prioritize and address as soon as posible.

On the meantime, there is no actual feasible alternative. You can "fake" a post relationship filter using some hooks and some metadata used to store the connection, but it is not going to be easy, funny or full functional without full support in Views core.

Hope it helps.

#436778

Hi Juan,

I'm really pleased to see you find my request a nice feature to add. I really hope to see it working soon.

At the moment I'm not using views filtering at all and managing the whole thing trough a custom made isotope filter.

I'm quite satisfied with the results but of course it would be awesome to do it right away within views.

Thanks for your support guys,
best regards
Carlo

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