Forums › Forums › Search & Filter Pro › How can I change the query args in the url
Tagged: CHANGE URL, meta_query
- This topic has 15 replies, 2 voices, and was last updated 6 years, 2 months ago by Trevor.
-
Anonymous(Private) September 28, 2018 at 2:54 pm #189626
Hi,
We have two forms for filtering our products, one of which is a tool for to help our customers choose the right product based on a lot of data.
It is quite complicated, but simply put they (among other simpler choises) choose a reference wind (22/23/24/24/26) and terrain class (1/2/3), and then in two range sliders they choose wind surface range (0-3) and weight range (0-300). Based on the chosen reference wind and terrain class I want the products that have values (in the corresponding meta box) within the chosen range to be displayed.
In the range sliders I only have values from one meta box (since I can’t add multiple), just to get the input objects in the form, so I made a function that I added with filter ‘sf_edit_query_args’ to change the meta query according to my wishes.
The meta query is changed as expected, but the result does not take the meta_query in consideration. It is showing the result based on the query in the url (&_sfm_prefix_ws_24_type_2=0+3&_sfm_prefix_weight_24_type_2=0+300 as default for these inputs).
I have tried using the filter ‘sf_results_url’ to remove them, but $url only returns the url without query args.
Is there any way to alter the url? Or any other way I could pull this off?
Kind Regards
Lisa KrigaTrevor(Private) October 1, 2018 at 1:12 pm #189778After you change the URL, somehow you would need to get the results to reload. I am not sure that can be done.
All this data is being stored in one meta field. I am not sure if it would work as separate meta fields (and thus separate sliders) either, if I understand that each post would have one set of data, and splitting it up would leave empty values in the other fields, which would cause the posts not to show in a search. If they had 0 in the other fields, that might work.
Anonymous(Private) October 1, 2018 at 2:50 pm #189780Depending on which values are chosen in the inputs for rw (22-26) and tc (1-3) the corresponding ws and fw-value is used in the sliders. That is, if I choose 22 as rw and 1 as tc then the values in those meta boxes for ws and fw are compared to the data chosen in the rangers (ws-22-1 and rw-22-1), so I basically would need a conditional range slider which is not available.
The code above is used with “sf_edit_query_args”. (I have asdo tried using “sf_results_url” as mentioned in the first text, but that didn’t work since it only gets me the base-url.)
But if this is not the way to use the filter, how is it suppose to work? I thought the filter “sf_edit_query_args” would alter the query for the search, what does it do then? Just in case that will give me some new idea on how to advance.
Otherwise I’ll just have to figure out a way to update the search query ’cause this is an important feature of this filter.
-
AuthorPosts