I have pagination set low in reading settings, which is a problem for search results. For the search.php template I'm looking for all returned results to be shown.
What do I need to change with this? This is showing all posts in the DB
<?php get_header(); query_posts( 'posts_per_page=-1&cat=' . $cat ) ?>
would be better to use something like this? how could this be applied to show all search results on one page regardless of reading settings?
<?php
function custom_posts_per_page( $query ) {
if ( $query->is_tax('mytaxonomy') || $query->is_category('mycategory') ) {
set_query_var('posts_per_page', 9);
}
}
add_action( 'pre_get_posts', 'custom_posts_per_page' ); ?>