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

I’m sorry for this scholar question, but I’m totaly confused with search in WordPress. What is the difference beetwen searchpage.php, searchform.php and search.php? Could anybody tell me how it all works? Thanks.

Related posts

Leave a Reply

2 comments

  1. 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( '/' ) . '" >
    <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.

  2. searchpage.php is a custom page that usually includes searchform.php.
    It offers functionality for the end-user to enter search criteria and press submit button.
    The results appear in search.php.