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 Disable Search Engine Indexing On A Particular Category In WordPress Blog Hi, Hi, Many wordpress users do not want to index...
  2. How To Convert Category Pages To Post Titles In WordPress Blog Hi, Many wordpress users wants to display Category Pages instead...
  3. How To Disable Search Engine Indexing For A Single Post In WordPress Blog? Hi, Many wordpress users do not want to indexed their...
  4. How to block your blog from the search engines? Hello All, Sometimes you may need to block your blog...
  5. Plugins: Google Blog Search Preview Google Blog Search Preview is a simple plugin for WordPress...

Leave a Reply

You must be logged in to post a comment.