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.
Written by Philip Norton.
Related posts:
5 Responses to “Change Number Of Search Results In Wordpress”
-
dan wilson | December 18th, 2009 9:33 pm #
Normally I would not post a comment, but you've put together a nice post here and I wanted to say thank you. -
chicago auto insurance | December 18th, 2009 10:58 pm #
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. -
Arlo | December 27th, 2009 8:57 pm #
You're missing an ampersand: -
Philip Norton | December 30th, 2009 3:31 pm #
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
-
Caleb | January 22nd, 2010 12:52 am #
thanks..i search long and hard for this extremely simple code