Home › Toolset Professional Support › [Resolved] hide posts in views 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.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
This topic contains 8 replies, has 2 voices.
Last updated by Minesh 2 years ago.
Assisted by: Minesh.
Hi
I would like to hide the view results until a user choose filter.
In this view:
hidden link
I am not a technical guy so need simple instructions, or maybe you can do it for me?
REMOVED ACCESS
Thanks
Ron
Hello. Thank you for contacting the Toolset support.
I've added the following code to "Custom Code" section offered by Toolset with the code snippet name "toolset-custom-code":
=> hidden link
add_filter('wpv_filter_query', 'func_hide_search_result_until_search_perform', 10, 3); function func_hide_search_result_until_search_perform( $query_args, $view_settings, $view_id ) { if($view_id == 60685 ){ if( !isset($_REQUEST['wpv_view_count'])) { $query_args['post__in'] = array(0); } } return $query_args; }
Can you please confirm it works as expected now:
=> hidden link
Hi
Thanks you
I doesn;t work is expected. As you see in the image, it shows 0 results for each category, and it show 2 sets of filters, one under the other.
If I switch to the backup toolset view I created yesterday before opening the ticket "writing-tasks-b-backup" everything works fine (but view shows posts as default before filtering, which is what I want to solve)
Thanks
Ron
Its due to AJAX and you will have to use the option "Full page refresh when visitors click on the search button with input values auto-updating" as with AJAX there is limited option to cover this feature and your layout is broken.
I've adjusted the code added to "Custom Code" section as given under:
add_filter( 'wpv_filter_query_post_process', 'func_hide_result_until_search_perform', 10, 3 ); function func_hide_result_until_search_perform( $query, $view_settings, $view_id ) { if ($view_id==60685 and !empty( $query->posts ) and !isset($_REQUEST['wpv_view_count']) ) { $final_result = array(); $query->posts = $final_result; $query->found_posts = count($final_result); // modify the count of found posts $query->post_count = count($final_result); // modify the count of displayed posts } return $query; }
Can you please confirm it works as expected: hidden link
Can you please check now. I've removed the additional filter that used to display at bottom of the search result.
Hi
I will need also to make sure that the original view, with the Ajax and no hiding, is working properly.
vieew
So I switched to the original view but now it shows to filter lines, above and bellow the posts, as seen in the image,
pls. remove also here the 2nd line of filters.
writing-taks-view-b-backup
Thanks
I've removed the bottom filter line from your following view:
- hidden link