Forums › Forums › Search & Filter Pro › Filtering on number range always empty.
- This topic has 7 replies, 2 voices, and was last updated 7 years, 7 months ago by
Trevor.
-
Anonymous(Private) September 7, 2018 at 9:26 am #187609
Hi,
I need to filter a posttype by year with a range slider. This is not possible by default with your plugin unfortunately.
So I made a custom meta field for the post type (made with Pods.IO) that gets filled in automatically by an action at save time that takes the year of the publication date and saves it to the post.
Then I made a filter with a range slider on that custom meta field.The filter shows the values correctly from lowest to newest, but the filter itself doesn’t work.
The resultspage is always empty and the slider has both handles on the lowest value.The filter in the URL shows : ?_sfm_post_year=1985+1985
Changing this to ?_sfm_post_year=1985+2018 still shows nothing.
The code for filling in the year is as follows:
add_filter('pods_api_pre_save_pod_item_publicationdata', function($pieces, $is_new) { $id = $fields['params']['id']; $new_year = intval(get_the_time('Y', $id)); $pieces['fields']['post_year']['value'] = (int) $new_year; return $pieces; },100,2);When I take a single value with a dropdown, the filtering does work. Only the slider doesn’t.
Any idea what’s wrong?
Thanks!
Trevor(Private) September 7, 2018 at 3:01 pm #187692If they are both going to the same page for results, then set one to Custom and enter the full URL in the setting for that, and switch Ajax off for that form. However, both forms must have the same fields in (even if hidden).
There might be problems if the field is a different format (so that the filter string is different).
-
AuthorPosts