Sep
24

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%

Related posts:
  1. How To Convert Category Pages To Post Titles In Wordpress Blog Hi, Many wordpress users wants to display Category Pages instead...
  2. How To Display Post Alphabetically In Wordpress Blog? Hi, WordPress organizes and displays posts in descending chronological order:...
  3. How To Add Author Page in Wordpress Blog Hi, In order to create an author page you will...
  4. How To Disable Search Engine Indexing On A Particular Category In Wordpress Blog Hi, Hi, Many wordpress users do not want to index...
  5. Code To Find List Of Posts Which Has No Tags In Wordpress Blog Hi, In order to find and display the untagged posts...

Leave a Reply

You must be logged in to post a comment.