Skip Navigation

[Resolved] Custom search view showing expected results

This support ticket is created 4 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 2 replies, has 2 voices.

Last updated by Minesh 4 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#1427693

Hi,

I have a custom search (as seen on hidden link) with two taxonomy filters and two numeric filters (amount from/to). All 4 filters have default labels. I expect that when a user does not make a selection (so the default label is active), the search does not use that filter.

My problem is that despite the default labels there is no search result if only one filter was used. I see that when the default label is active this gives a url string with value '0'

hidden link

But there is no "locatie-woning" with value '0'.

So I expect that when 'wpv-soort-woning' had a value and 'wpv-locatie-woning' not, all posts are showed no matter what wpv-locatie-woning it is.

Thanks!
Martijn

#1427737

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

We have known issues with range filters and its already reported to our next level support.

I'll get in touch with you once I get some updates on it. Please hold on for further updates.

For now, there are two workarounds:
1)
You can downgrade Views plugin to version 2.9.4
OR
2)
Use the "wpv_filter_query" hook:
- Add the following code to your theme's functions.php file:

add_filter( 'wpv_filter_query', 'func_filter_min_max_search', 1000 , 3 );
function func_filter_min_max_search( $view_args, $view_settings, $view_id ) {
 
    if ( ( !is_admin() && isset($view_settings['view_id'] ) ) && ( ($view_settings['view_id'] == 286) ) )
    {
        if ( (isset($view_args['meta_query'])) && (!empty($view_args['meta_query'])) ) {
 
            $target_field = "wpcf-woning-vraagprijs";
 
            $url_param_min = "wpv-wpcf-woning-vraagprijs-vanaf";
            $url_param_max = "wpv-wpcf-woning-vraagprijs-tot";
 
            foreach ($view_args['meta_query'] as $key => $value) {
                if(is_array($value)) {
                    if ($value['key'] == $target_field) {
                        $required_index = $key;
                    }
                }
            }
 
            if ( isset($required_index) ) {
                $min_value = $_GET[$url_param_min];
                $max_value = $_GET[$url_param_max];
                $view_args['meta_query'][$required_index] = array('key' => $target_field, 'value' => array($min_value, $max_value), 'type' => 'NUMERIC', 'compare' => 'BETWEEN' );
            }       
        }   
    }
 
    return $view_args;
}
#1431289

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Our Devs shared a hotfix that will help you to fix this issue and I would like to apply that hotfix on your install.

Can you please install Views 3.0.1 plugin version and send me working FTP access details as the one you sent is not working at this end.

I have set the next reply to private which means only you and I have access to it.