Skip Navigation

[Resolved] Setting empty search result by the default page

This thread is resolved. Here is a description of the problem and solution.

Problem:
Setting empty search result by the default page when view load

Solution:
you can use view's filter hook wpv_filter_query in order to display no results by defult.

Please try to add following code to your current theme's functions.php file.

add_filter( 'wpv_filter_query', 'show_empty_results_default_func', 10,2 );
function show_empty_results_default_func( $query_args, $setting ) {
    if($setting['view_id'] == 9999){  
 
        if( !isset($_GET['wpv_view_count'])){
            $query_args['post__in'] = array(0);
        }
 
    }
    return $query_args;
}

Where:
- Replace 9999 with your original view ID

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

This support ticket is created 6 years, 3 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 Yoshifumi Yamada 6 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#1123596

I made a custom search page and I found the all the custom post data appear below the search form.
However I need the search page without any the custom post data output by default.
When a user select the categories and press the submit button, then the result of post data shall appear.
This is what I am intending to do.
Please advise me.

#1123673

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - you can use view's filter hook wpv_filter_query in order to display no results by defult.

Please try to add following code to your current theme's functions.php file.

add_filter( 'wpv_filter_query', 'show_empty_results_default_func', 10,2 );
function show_empty_results_default_func( $query_args, $setting ) {
    if($setting['view_id'] == 9999){

        if( !isset($_GET['wpv_view_count'])){
            $query_args['post__in'] = array(0);
        }

    }
    return $query_args;
}

Where:
- Replace 9999 with your original view ID

#1124345

My issue is resolved now. Thank you!