Change Number Of Search Results In Wordpress

27th November 2009 - 2 minutes read time

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.

Comments

Permalink
Normally I would not post a comment, but you've put together a nice post here and I wanted to say thank you.

dan wilson (Fri, 12/18/2009 - 21:33)

Permalink
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.

chicago auto i… (Fri, 12/18/2009 - 22:58)

Permalink

You're missing an ampersand:

Arlo (Sun, 12/27/2009 - 20:57)

Permalink
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 :)
Permalink
thanks..i search long and hard for this extremely simple code :)

Caleb (Fri, 01/22/2010 - 00:52)

Permalink
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! :)

Luke Gedeon (Wed, 03/17/2010 - 14:35)

Add new comment

The content of this field is kept private and will not be shown publicly.