Codex tools: Log in
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.