Change Number Of Search Results In 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.


Normally I would not post a comment, but you've put together a nice post here and I wanted to say thank you.
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.

You're missing an ampersand:

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 :)
Philip Norton
thanks..i search long and hard for this extremely simple code :)
Thanks! Exactly what I was looking for! It is a little confusing that you can put the code anywhere near the top and that you have to put in several different files that are not the same from theme to theme. But it works! :)

Add new comment

The content of this field is kept private and will not be shown publicly.
2 + 18 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.