Hi,
Sometimes wordpress users want make the search results unlimited. This is a code which allows search to return unlimited results, altering the standard WordPress Loop by using a custom query. If you have a search template search.php you can simple add the following line of code above your Loop.
Find:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
Add this above:
<?php if (is_search()) { $posts=query_posts($query_string . '&posts_per_page=-1'); } ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
Make sure you put this code in your search.php only otherwise unlimited posts on your index or archive pages. The -1 you see can be changed to any positive integer to limit the posts to a number you choose as well.
That’s it!
Thanks,
Shane G.
Popularity: 1%














