Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

User:T31os/searchform

WordPress allows theme's to provide their own search form by simply creating a searchform.php in the folder of the theme.

Previously an example search form was provided with the default theme, this allowed users to refer to this file as an example, however it has since been removed, leaving users wondering where to look for examples on how to write their search forms should they wish to write one.

Below is the code output by get_search_form() aka the default search form, usually called by the theme's search.

<form role="search" method="get" id="searchform" action="<?php echo get_option('home'); ?>">
	<div>
		<label class="screen-reader-text" for="s">Search for</label>
		<input type="text" value="<?php echo esc_attr( apply_filters( 'the_search_query' , get_search_query() ) ); ?>" name="s" id="s" />
		<input type="submit" id="searchsubmit" value="Search" />
	</div>
</form>

Although not immediately obvious, there are actually examples shown on the codex entry for get_search_form.

This article is a ROUGH DRAFT. The author is still working on this document, so please do not edit this without the author's permission. The content within this article may not yet be verified or valid. This information is subject to change.