Support Forums

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: ,

Viewing 7 posts - 1 through 7 (of 7 total)
  • Juan Gonzalez

    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

    There 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?

    Juan Gonzalez
    This reply has been marked as private.
    Trevor Moderator

    It may be that you can do this using this filter:

    If you need help with the coding, I would need to refer this to our plugin developer, Ross, for his input.

    Juan Gonzalez

    Hi 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

    Hi 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.


    Juan Gonzalez

    Hi Ross, thanks for the response, it’s a shame is not currently possible. I’ll look forward to it.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.