How to create a useful WordPress search results page
One very useful function of WordPress is its integrated search. From WordPress 2.5 on, you can search for posts and pages. By adding the searchform.php file to your theme folder. (Searchform.php should contain a code like this:
<form method="get"
id="searchform" action="<?php bloginfo('home'); ?>/">
<div><input type="text"
value="<?php echo wp_specialchars($s, 1); ?>"
name="s" id="s" />
<input type="submit"
id="searchsubmit" value="Search" />
</div>
</form>
and by including this snippet to your template:
<?php include (TEMPLATEPATH . '/searchform.php'); ?>
, your search engine is ready for use. But what about the search results?

After a search has been performed, WordPress uses the search.php template to display the results. By adding just a few lines of code, we can make the results page more useful to those who search your blog. What do we want to display?
- First of all, we want to display the list of results of posts and pages that corresponds to the search terms. To give the reader a better overview, we want only titles and excerpts of content to be shown.
- Display again the search term entered by the site visitor. Maybe there was a typographical error? This can be done by calling the function
<?php the_search_query(); ?>
- Provide info to the visitor on how to get along if the search provided no useful results.
Feel free to download my example of a search results page and modify it to fit your needs
