Search in WordPress – Difference of searchpage.php, searchform.php and search.php?

Your question is most likely referring to a specific theme, but I’ll answer it for the current default Twenty Ten (WordPress Theme) as it’s well documented. You find it in the wp-content/themes/twentyten directory.

The main search template in there is search.php. It is the template file to display the search page. Which means either only the search form or when called for a search, the search results as well.

searchform.php is a template part, so a fragment to hold the search form. The default theme does not ship with it by default, but if it exists it will load it instead of a hardcoded search form. Here is the default search from:

<form role="search" method="get" id="searchform" action="' . home_url( "https://wordpress.stackexchange.com/" ) . '" >
<div><label class="screen-reader-text" for="s">' . __('Search for:') . '</label>
<input type="text" value="' . get_search_query() . '" name="s" id="s" />
<input type="submit" id="searchsubmit" value="'. esc_attr__('Search') .'" />
</div>
</form>'

That is done in the wordpress function get_search_form() which is part of the core package and used by many themes including Twenty Ten.

searchpage.php is something specific to another theme I guess, as it is not used within the default theme and worpdress core. I assume by name, that it’s having the same or a similar meaning as search.php but being specific to some other theme.

Leave a Comment