[Resolved] don't show results until a filter is applied
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
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.
marF confirmed that the issue was resolved on 2024-03-21 12:58:07.
This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.