Display all search results

The quick and dirty way to do it would be to use query_posts again, doubling the number of database calls.

<?php if (have_posts()) : ?>
<?php query_posts('showposts=999'); ?>

Better would be to add this to functions.php, altering the original query before it is executed:

function change_wp_search_size($query) {
    if ( $query->is_search ) // Make sure it is a search page
        $query->query_vars['posts_per_page'] = 10; // Change 10 to the number of posts you would like to show

    return $query; // Return our modified query variables
}
add_filter('pre_get_posts', 'change_wp_search_size'); // Hook our custom function onto the request filter

If you want to show an unlimited amount of posts, use -1.

Leave a Comment