Skip Navigation

[Resolved] I need help to make a custom filter

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

Problem:

I'm looking at how to make this filter, will it be possible?
https://cdn.toolset.com/wp-content/uploads/2018/07/1042087-Web_1920_1.png?x28969

Solution:

There isn't such a built-in feature within Views plugin, it needs custom codes, for example, you can setup some dropdown menu manually as the screenshot you mentioned above, use them to pass URL parameter to your view, then use Views filter hook "wpv_filter_query" to trigger a PHP function

https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

In this PHP function, get the URL parameters, change the views query to what you want according to the URL parameter values

https://codex.wordpress.org/Class_Reference/WP_Query

Relevant Documentation:

https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

This support ticket is created 6 years, 4 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 carlos-a-rojas-r-19180R 6 years, 4 months ago.

Assisted by: Luo Yang.

Author
Posts
#1042087
Web 1920 – 1.png

Hello!

I'm looking at how to make this filter, will it be possible?

it is possible?

#1069135

Hello,

There isn't such a built-in feature within Views plugin, it needs custom codes, for example, you can setup some dropdown menu manually as the screenshot you mentioned above, use them to pass URL parameter to your view, then use Views filter hook "wpv_filter_query" to trigger a PHP function
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

In this PHP function, get the URL parameters, change the views query to what you want according to the URL parameter values
https://codex.wordpress.org/Class_Reference/WP_Query

#1073490

I found an alternative way to do this, not equal but similar