I have a custom search at hidden link
Before any search query has been entered, the search results show all products. I don't want anything to show up until a search query is entered. How can I achieve that?
Hi Chris,
Thanks for asking! I'd be happy to help.
To make sure no results are shown from the view until a search term has been used, you can use conditional display block ( ref: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/ ) to check the value of the "wpv_post_search" URL parameter, through the "wpv-search-term" shortcode ( ref: https://toolset.com/documentation/user-guides/views-shortcodes/#vf-214940 ).
You'll note that when a search term is used in the view, it is appended in the URL parameter "wpv_post_search".
To get its value following shortcode can be used:
[wpv-search-term param="wpv_post_search"]
This can be combined in a conditional block like this:
[wpv-conditional if="( '[wpv-search-term param="wpv_post_search"]' ne '' )"]
A search term exists
[/wpv-conditional]
Likewise, this same conditional block can be used in the view's "Loop Editor" section, to wrap everything within the shortcodes "[wpv-layout-start]" and "[wpv-layout-end]".
I hope this helps and please let me know if you need any further assistance around this.
regards,
Waqar
My issue is resolved now. Thank you!