WordPress search form snippet

David Nash wordpress Leave a Comment

This is code to use for a search form, for example in the header area of a WordPress theme. It retains the previous search query in the text field.

[html] <form action="<?php echo home_url(‘/’); ?>">
<input type="text" name="s" value="<?php the_search_query(); ?/>" />
<button type="submit">Search</button>
</form>
[/html]

Leave a Reply

Your email address will not be published. Required fields are marked *