Dear Nigel
Okay, yes, I agree about those 5 seconds and ongoing showing.
Second, yes, I need a solution, where we have in a first stage no result showing. And once the user is either choose something from the drop downs or use the text search, it will showing results according.
If You can help me with this wpv_filter_query API filter, would be great, I am not 100% familiar how to do that.
Regards
Nigel
Supporter
Languages:
English (English )
Spanish (Español )
Timezone:
Europe/London (GMT+00:00)
You can add this code to your site (at Toolset > Settings > Custom Codes), you should just need to edit the ID of the View:
/**
* No initial results
*
* Don't show View results until a filter has been applied
*
* Tests for custom field filters, taxonomy filters, or text searches
*/
function tssupp_no_initial_results( $query_results, $view_settings, $view_id ){
$target_views = array( 226 ); // Edit to add IDs of Views to add this to
if ( in_array( $view_id, $target_views ) ) {
// if there is a search term set
if ( !isset( $query_results->query['meta_query'] ) && !isset( $query_results->query['tax_query'] ) && !isset( $query_results->query['s'] ) ) {
$query_results->posts = array();
$query_results->post_count = 0;
$query_results->found_posts = 0;
}
}
return $query_results;
}
add_filter( 'wpv_filter_query_post_process', 'tssupp_no_initial_results', 10, 3 );
You will need to delete the text for "No items found" from the View.
Hi Nigel
I have done this, but still the same result. Anything else I need to check or change?
Regards,
Nigel
Supporter
Languages:
English (English )
Spanish (Español )
Timezone:
Europe/London (GMT+00:00)
No. You remembered to edit the View ID?
I tested the code on my own site with a similar set up using automatic pagination and it works as expected, so it should work on your site.
Dear Nigel
It seems as it is working, when I put the code in "Appearance, Theme Editor -> functions.php
I am not sure what the big different is, but if You can clear that with me, would be great.
Regards,
Nigel
Supporter
Languages:
English (English )
Spanish (Español )
Timezone:
Europe/London (GMT+00:00)
I suspect when you added the code in the Toolset settings you didn't activate the code snippet?
There is little practical difference between adding the code in Toolset settings vs. editing your theme's functions.php file, except it is supposed to be more convenient ( 🙂 ) and means the code isn't lost if you change theme.
But the important thing is whether the code works, and it sounds like it does, yes?
Sorry it took a while to get to the solution, the other method should be simpler, but it can't work very easily with your View that has automatic pagination.
My issue is resolved now. Thank you!