Web Hosting Geeks | Web Hosting Experts
Need help? Call us 1(866)TOP-HOST

14120 reviews 1680 hosting providers

Questions & Answers

Number of search results displayed in a listing page in WordPress

Apr 27, 2012 by SaraSX
Hi there,
I am using a wordpress template for my website and I want to increase the number of search results displayed in a listing page in my wordpress site instead of full posts being displayed one above the other, and I’m not sure how to do it.
Can anyone please help me figure out how to do this.

thanks

1 Answer

0 votes
Apr 27, 2012 by RalphK
From your WordPress dashboard, select Appearance > Editor, then under Theme Files select Search Results (search.php). This will open up the search.php code for editing.
Look for the following line;
<?php if (have_posts()) : ?>
and place the following line above it;
<?php query_posts('showposts=20'); ?>
In my template it looked like this;
<div id="content">
<?php query_posts('showposts=20'); ?>
<?php if (have_posts()) : ?>
Assign a number  to "showposts=", this number will be the number of search results displayed in a listing.