Tell us what you are trying to do? - I would like only the search/filtering boxes to show on the page and no results until either a text search or taxonomy select list is chosen. Right now, even though I have added in the View as described in the below thread, the full results are still showing.
Also, I don't want to have the option to show All Results. Only filtered/searched ones.
Is there any documentation that you are following?
Is there a similar example that we can see? I found this support thread but it isn't working for me: https://toolset.com/forums/topic/do-not-show-loop-output-until-submit-button-in-filter-editor-is-selected/
I have added in the View like this:
[wpv-form-view name="filterable-documents" target_id="self"]
[wpv-view name="filterable-documents" view_display="layout"]
What is the link to your site? hidden link
Thanks!
And if I can ask one other thing. The categories on that page also have sub-categories. If someone does a filter or a search, it would be nice to show something like DOCUMENT CENTRE > MAIN CATEGORY > SUB-CATEGORY by each result so that the end user can be oriented to where they are in the document tree.
Hi, if you would like to display no results until some filter is applied, you can add a bit of custom code. Here is a code snippet you can use:
function tssupp_no_initial_results( $query_results, $view_settings, $view_id ){
$target_views = array( 123,456 ); // 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'] ) && !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 );
Replace 123,456 with a comma-separated list of numeric View IDs where you want to apply this filter. Then you can add this code in a child theme's functions.php file, or in a new code snippet in Toolset > Settings > Custom Code.
If someone does a filter or a search, it would be nice to show something like DOCUMENT CENTRE > MAIN CATEGORY > SUB-CATEGORY by each result so that the end user can be oriented to where they are in the document tree.
You can add this information to each result in the View's loop. You can use the wpv-post-taxonomy shortcode to display information about a taxonomy hierarchy. We have documentation about that shortcode available here: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-taxonomy
If you have questions about that, we can start a new ticket and discuss in more detail.
Thank you. I will open another ticket to discuss the displaying of taxonomy.
I was also looking for this functionality, and this solution worked. Please consider adding "only show search results after user input" as an option to the view builder.
Hi joonaN, please submit your request here to add your vote for this feature: https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/