Skip Navigation

[Resuelto] Hide Default return values in an Ajax parametric search view

This support ticket is created hace 7 años, 11 meses. 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
- 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 8:00 – 17:00 -
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Etiquetado: 

This topic contains 1 respuesta, has 2 mensajes.

Last updated by Dat Hoang hace 7 años, 11 meses.

Assigned support staff: Dat Hoang.

Autor
Mensajes
#271443

I am trying to:
I have created a parametric search view that selects a custom post type called resources, I have also creates a custom taxonomy called states for my resources post type.
In my view I have a select menu of states and when the user selects a different state it refreshes the view and displays the resources that belong to that state. All of this is working fine although I'm noticing when the page first loads the view pulls default resources into the view. I need a way not to show default resources when the page first loads and still make use of loading content into the same page.
I visited this URL:
hidden link
I expected to see:
No returned resources until a state is selected.
Instead, I got: default values.

#271499

Looks like you resolved the problem by yourself?

The link hidden link seems to work as your need.

If it does not work, please use the filter "wpv_filter_query" to ignore the page loading the results first.
The example code:

add_filter( 'wpv_filter_query', 'show_empty_default_func', 10, 2 );
   
function show_empty_default_func( $query_args, $setting ) {
    if($setting['view_id'] == 56 && !isset($_REQUEST['action']))
    {
        $query_args['post__in'] = array(0);
    }
    return $query_args;
}

Please change your searching view id, in my test, it's '56'.

The guide "wpv_filter_query": https://toolset.com/documentation/user-guides/views-filters/wpv_filter_query/