Hi, I don't want results to be displayed in a search view until a filter is applied (on hidden link).
I found this solution but it doesn't work in my case: https://toolset.com/forums/topic/dont-show-any-results-until-filter-is-applied/
I think it's because of the search view filter type. I use taxonomy filter and also a field called "Year" (dropdown Custom Search Filter).
Hello. Thank you for contacting the Toolset support.
Yes - As you have taxonomy filter added only, I've just modified the code as given under. Can you please try to use the following code and try to resolve your issue:
function tssupp_no_initial_results( $query_results, $view_settings, $view_id ){
$target_views = array( 51); // Comma-separated list of View IDs
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'] ) ) {
$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 );
Can you please share admin access details and tell me where exactly you added the code I shared and let me review whats going wrong with your setup.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.