How to set posts per page using WP_Query()

query_posts will do the query again (destroy current wp_query and create a new one and then doing the query with the parameters you pass to it)

To get the same behaviour after setting the new parameter with set_var you need to query the database again using something like this

 $wp_query->set('posts_per_page', 1);
 $wp_query->query($wp_query->query_vars);

Leave a Comment