Read wordpress get_search_query empty for more information.

It retrieves the contents of the search WordPress query variable. So apparently, when WordPress sees an empty search string it doesn’t even use it and sends the search to the home page.

You offer a search input field, and someone hits the submit button unintentionally, without any term entered. The resulting URI looks like this: example.com/?s=. It shows the same content as your front page. In fact, it is the front page.

No one needs that.

Add great search to your WordPress site @9 usd per month

Empty results are handled using get_search_query() function but this can get quite tricky if not handled properly. If you are not that tech-savvy, it is easier to go for a fully configurable search bar like ExpertRec. This will let you set up no results pages easily.

Searches related to WordPress get_search_query empty

You may also like