I'm trying to set the number of posts_per_page dynamically using my own variable. This code works fine:
query_posts( $query_string . "&posts_per_page=" . $myvar )
// then display the loop using get_template_part( 'loop' );
That works fine, but I would like to know how to do it using $wp_query instead of query_posts. However, this does not work:
$wp_query->set('posts_per_page', $myvar)
// then display the loop using get_template_part( 'loop' );
That has no effect on the number of posts displayed. Am I using the set method incorrectly, or is there something I'm missing?