Skip Navigation

[Resolved] Custom Search results display (no posts) until the search

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

Problem:

In this ticket the user wanted to start out with a blank results page when no search has yet been performed.

Solution:

This can be achieved by using the hook below. Add the following to your toolset custom functions in Toolset -> Settings -> Custom Code.


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;
}

Change the '9999' to the ID of your view and this should cause your view to start with an empty search page.

This support ticket is created 5 years, 5 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 16 replies, has 2 voices.

Last updated by Shane 5 years, 5 months ago.

Assisted by: Shane.

Author
Posts
#1339203

Hi Shane,
Ok great - that is good to know.
I have tried to switch to the AJAX Custom Search Settings, but it didn't work.
As a last request from me on this ticket, please could you give me some links to the documents that can help me get the AJAX Custom Search Settings working with Views and relevanssi?
I'll work my way through them and see if I can figure it out.
Is there any reason not to use AJAX?
Thank you very much for your patience and help. It's all worked out well.
All the best,

PS are these tickets private? I would prefer them to be. (It is my first ticket).

#1339209

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi,

We do have some documentation on Revelanssi and our views plugin.
https://toolset.com/documentation/user-guides/searching-texts-custom-fields-views-relevanssi/

Finally No these tickets are public as this is a public forum. However I can enable private responses for special items such as website credentials, duplicator packages etc.

Thanks,
Shane