Skip Navigation

[Resolved] How to force blank search to return no results

This support ticket is created 4 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by catrionaD 4 years, 5 months ago.

Assisted by: Waqar.

Author
Posts
#1634351

Blank search returns all results

I would like a blank search to return no results

#1634461

Hi,

Thank you for waiting.

To make sure that the search results are only shown when some text has been entered into the text search field, you can use the "wpv-search-term" shortcode ( ref: https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-search-term ), in a conditional output ( ref: https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/using-shortcodes-in-conditions/ ).

For example, the structure of your view's content inside the "wpv-items-found" tags in "Loop Editor" section will look like this, with these conditional blocks:


[wpv-items-found]
	[wpv-conditional if="( '[wpv-search-term param='wpv_post_search']' ne '' )"]
		<!-- wpv-loop-start -->
			.....
		<!-- wpv-loop-end -->
	[/wpv-conditional]
	[wpv-conditional if="( '[wpv-search-term param='wpv_post_search']' eq '' )"]
		Please enter some text in the search field to view the results!
	[/wpv-conditional]
[/wpv-items-found]

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1634541

Thanks Waqar, my issue is resolved now. Thank you!