Show Your Search Query in WordPress

Wouldn’t you like to be able to display the actual search term entered by your user on the search results’ page? Good thing there is a very simple way in WordPress to do that with the_search_query function. Just open up your search.php file and enter:


to display the search term that was entered. So something like this:

would display something that looked like this:
Search Results for “the search term”
Another cool little trick it to add the number of search results. Use this code:

post_count;
echo $num.' search results for "'; the_search_query();
?>

to display something like:
18 search results for “the search term”

Share this:

Email
Facebook
Twitter
Pinterest
Pocket

Premium Themes for WordPress

Looking for an easy-to-use Premium Theme for WordPress? Check out Themes by bavotasan.com and have your site up and running in no time.

Use this WordPress website builder to build powerful websites in no time for your or your clients.

WordPress Hosting

WP Engine – designed from the ground-up to support and enhance the workflow of web designers.

Bluehost – providing quality web hosting solutions since 1996.

About the author

Picture of Luke Perrie

Luke Perrie