Codex tools: Log in / create account
Contents |
Displays the search query for the current request, if a search was made.
This function can be used safely within HTML attributes (as in the "search box" example, below).
<?php the_search_query(); ?>
If you have just performed a search, you can show the last query in the search box:
<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
<div>
<input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
<input type="submit" id="searchsubmit" value="Search" />
</div>
</form>
You can display the search string on search result pages
<p>You searched for \" <?php the_search_query() ?> \". Here are the results:</p>