Skip Navigation

[Resolved] Need Range filter in Toolset (from/till)

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

Last updated by Luo Yang 1 year, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#2360523
range-filter3.jpg

I agree there is an issue when you put two range filters in the same post view, I will escalate this issue.

Currently, please try these:
Edit the new post view:
hidden link
find and click into the filter "prijs", click button "Edit filter", and change the filter settings, see my screenshot range-filter3.JPG

#2364485
Screenshot_3.jpg

Hi, sorry for the delayed response, I've been away for a few days.
I did as described and set the filter to Between (even though the other View has 'between, lower end' and 'between, higher end'), saved the shortcode, clicked edit again, the filter was still/again on 'equal to'. It doesn't stick to Between.

#2364967

It should be a bug of range filter when use custom option values, does it effect on frontend?
hidden link
I have tried it in your website, it seems to be work fine.

#2366855

Your url shows 0 results.
I needed to edit both price and mileage filters because I needed more values.
Whatever filter I set, it always shows 0 results 🙁

#2370577

Sorry for the delay answer, I have tried your test site credentials again, it does not work any more:
https://toolset.com/forums/topic/need-range-filter-in-toolset-from-till/#post-2342029
Please provide the new credentials in below private message box, thanks

#2370609

I have extended the temp login with 1 month

#2372367

Thanks for the details, I have done below modifications in your website:
1) Dashboard-> Toolset-> Settings-> Custom Code, add one item "range-filters", with below codes:

add_filter('wpv_filter_query', function($query_args, $settings, $view_id){
	if($view_id == 182 && isset($query_args['meta_query'])){
    	foreach( $query_args['meta_query'] as $k => $v){
        	if( in_array($v['key'], array('wpcf-kilometerstand', 'wpcf-prijs'))){
              	$query_args['meta_query'][$k]['type'] = 'NUMERIC';
              	$query_args['meta_query'][$k]['compare'] = 'BETWEEN';
            }
        }
    }
	return $query_args;
}, 99, 3);

It will override those two custom field filter settings: kilometerstand and prijs

2) Edit the post view "Voertuigen Filter":
hidden link
in section "Custom Search Settings", choose options:
- Let me choose individual settings manually-> Update the View results only when clicking on the search button-> Reload the page to update the View results
- Always show all values for inputs

Since you are using custom values in the select fields, the AJAX feature won't work as expected, so you can disable the AJAX as step 2)

Please test again, check if it is fixed.

More help:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
When displaying a View listing posts, this filter is applied to the arguments being generated by the View settings before they are passed to the WP_Query class.

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