Change Number Of Search Results In Wordpress

27 November, 2009 | Wordpress

Wordpress allows administrators to change the number of posts that are printed out on a page at once on the page Settings > Reading. However, this also has an impact on the number of search results that Wordpress will display. In order to keep the size of the home page down many Wordpress admins will reduce the number of articles to two or three. This can instantly make search results with only a few results reach many pages.

To get around this you will need a template called search.php, this is the template that Wordpress will use when printing out the search results. Towards the top of this file (anywhere above The Loop) add the following code.

<?php query_posts($query_string . '&showposts=10'); ?>

The $query_string variable is the currently used query string that generated the search results. Just set the value of the showposts variable to be the number of posts you want to display in the search results.

Written by Philip Norton.

Related posts:

5 Responses to “Change Number Of Search Results In Wordpress”

  1. dan wilson |
    Normally I would not post a comment, but you've put together a nice post here and I wanted to say thank you.
  2. chicago auto insurance |
    Thanks for the post. If you don't mind my asking, what WP theme are you using? Is it available Free or is it a custom design? Thanks.
  3. Arlo |
    You're missing an ampersand:
  4. Philip Norton |
    Hmm... Wordpress seems to have eaten your code there. Never mind, I think I see where the ampersand was missing from. Thanks for pointing that out :)
  5. Caleb |
    thanks..i search long and hard for this extremely simple code :)

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>