There is a new way to get support - via the support tab in your account.
Our support systems are changing, for the better. You'll be able to manage all your support requests from your account, and respond to any tickets via email.
These support forums are now closed - existing tickets will be closed after a month.
Support Forums › Forums › Search & Filter Pro › Change filter value before getting the posts
Tagged: search results, V3
- This topic has 6 replies, 3 voices, and was last updated 1 week, 1 day ago by
Juan Gonzalez.
- Juan Gonzalez(Private) February 2, 2021 at 5:40 am #274897
Hi! I would like to know if there is a hook or something that I could use to alter the value of a filter before getting the posts. What I want to do is a range that works as follows:
I have a post type that has a price meta value. The price can be any number.
I have a search filter for that meta value and whant it to be a range field, with the min value being 1 and the max value being 100.
I want that, if anyone select 100 as the max value, the results would show that have 100 or more as their value.As far as I know, I can’t accomplish this using the form settings when creating the search form, so what I was looking for, is to have a way to do execute a code like:
If ( field_value == max_field_value) {
field_value = 99999999
}Thanks in advanced!
Trevor Moderator(Private) February 2, 2021 at 9:36 am #274941There may well be a way, yes. Are you able to send me a live link/URL to your search page so I can take a look?
Trevor Moderator(Private) February 3, 2021 at 7:09 am #275183It may be that you can do this using this filter:
https://searchandfilter.com/documentation/action-filter-reference/#edit-query-arguments
If you need help with the coding, I would need to refer this to our plugin developer, Ross, for his input.
Juan Gonzalez(Private) February 5, 2021 at 8:47 pm #275427Hi Trevor, thanks for the response. I tried using the hooks that you mention but it seems the search filter values are not passed in that query, this is what the var_dump of the query looks like
array (size=10) 'paged' => int 1 'search_filter_id' => int 156 'search_filter_override' => boolean false 'posts_per_page' => int 5 'post_status' => array (size=1) 0 => string 'publish' (length=7) 'meta_query' => array (size=3) 0 => array (size=4) 'key' => string 'end_date' (length=8) 'value' => string '20210205' (length=8) 'type' => string 'DATE' (length=4) 'compare' => string '>=' (length=2) 1 => array (size=4) 'key' => string 'status' (length=6) 'value' => string 'closed' (length=6) 'type' => string 'CHAR' (length=4) 'compare' => string '!=' (length=2) 2 => array (size=4) 'key' => string 'status' (length=6) 'value' => string 'cancelled' (length=9) 'type' => string 'CHAR' (length=4) 'compare' => string '!=' (length=2) 'post_type' => string 'property' (length=8) 'is_search' => boolean true 'orderby' => array (size=1) 'date' => string 'DESC' (length=4) 'lang' => string 'en' (length=2)
so the values for the price and other filters are not being passed in that array.
Ross Moderator(Private) February 17, 2021 at 10:42 am #275742Hi Juan
I’ve been doing a pass of these forums and realised I had never got back to you, apologies.
Unfortunately I can’t see a way to do what you want.
Essentially the issue is that the meta query for price is not in the query – and that’s because we peform that part in a custom query, and return the IDs.
So right now, I can’t see a way for you to condtionally modify those filters.
I’m going to tag this post with
v3
– as in, something I would like to add to v3, once the intial release is out.Thanks
Juan Gonzalez(Private) February 20, 2021 at 7:17 pm #275760Hi Ross, thanks for the response, it’s a shame is not currently possible. I’ll look forward to it.
- AuthorPosts
You must be logged in to reply to this topic.
Support Hours
Our support hours are:10am - 5pm (GMT), Monday - Friday
Please be aware that tickets opened over the weekend will looked at on Monday.