I want to show a specified number of posts that come back for a given search query on the search results page so I am using the following search loop:
function childtheme_search_loop() {
$my_query = new WP_Query('posts_per_page=10');
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<div id="post-<?php the_ID() ?>" class="<?php thematic_post_class() ?>">
<?php thematic_postheader(); ?>
<div class="entry-content">
<?php thematic_content(); ?>
</div>
<?php thematic_postfooter(); ?>
</div><!-- .post -->
<?php endwhile;
}
add_action('thematic_searchloop', 'childtheme_search_loop');
This returns 10 of the posts for the query. The problem I am having is with pagination - when you go to Page 2 of the results, it is still showing the first 10 posts and you can never access the next 10 posts. In addition, it is showing pagination based on 3 posts per page which is what I have in the Reading settings in wp-admin so it is listing 7 pages, even though I only have 24 posts.
What's more, if I set ('posts_per_page=-1') I get all the posts on one page but the pagination is still there.
How can I adjust this search loop to return a specified number of posts and then paginate the remaining results?