Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

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.

share|improve this answer
3  
searchpage.php has an article in the Codex and you can find some tutorials on creating it, but indeed, it seems to be a complete search form with hints, like the one on this site. Maybe in earlier versions of WP search.php was only used to display results and not as a "search start page" when no query was entered? –  Jan Fabry Nov 17 '10 at 13:48
    
Thanks, I realized it. It's just for the specific themes. –  glazsasha Nov 17 '10 at 14:10
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.