Skip Navigation

[Resolved] It´s possible create a select tag whit ranges of numbers for filter?

This support ticket is created 5 years, 9 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.

Our next available supporter will start replying to tickets in about 1.76 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 3 replies, has 2 voices.

Last updated by Nigel 5 years, 9 months ago.

Assisted by: Nigel.

Author
Posts
#955774
filtro.jpg

Hello!
I am looking for a way to create a select and that your options are range of numbers (minimum - maximum) to be able to segmetar the searches.

It's possible?

#956408

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Screen Shot 2018-07-26 at 09.44.53.png

Hi Carlos

You can filter based upon a range, but it requires two filter inputs, one for the minimum value and one for the maximum value.

In the screenshot you can see the dialog when I am inserting a filter in a View for a field "Cost". When I select "between" for the comparison I get additional options for the two filters (e.g. I can edit the label for the lower end to, say, "Cost from" and for the upper end to "Cost to").

The option "Using existing field values" will populate the select options based upon the actual data from the posts.

You can manually set values (e.g. 100, 200, 500, 1000), but you would probably want to display different values in the from selector than the to selector.

When you insert the filter with the between comparison it will insert two wpv-control-postmeta shortcodes, one for min and one for max. You can place the cursor in one of these shortcodes then click the edit filter button and you can then choose "Using manually entered values" and enter the values specific to that filter.

#956452

HI Nigel

Thanks for the answer. but dont work´s for me =/ i am trying to follow this way https://toolset.com/forums/topic/seting-a-filter-by-price-range/ can you helpme with this solution?

#956466

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

Hi Carlos

Unfortunately the post you linked to doesn't contain a complete solution, it just shows you how to make the initial set-up so that you are then in a position to add custom code to take the modified search parameters and then run some custom code to intercept and change the query variables used to retrieve matching posts from the database.

But you need to provide the custom code. You need to understand how to split the search parameters (which have the range as a string) into separate lower and upper values, which you then use to set the meta_query arguments for the query.

If you want to try that and get stuck on something specific I can help you, but if you don't think it is something you can do you'd need to get a developer to do it for you. We maintain a list of Toolset Contractors that you can approach here: https://toolset.com/contractors/

You can, of course, do it the normal Toolset way with separate min and max filters as I described above.

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