[wp-hackers] query_posts

Mike Little wordpress at zed1.com
Wed Dec 21 11:34:31 UTC 2011

On 20 December 2011 18:53, IC IC <icwordpress at gmail.com> wrote:

> When you run the query_posts( 'posts_per_page=5' ); does it really
> throw away the original query and re-run the same query - just to
> compile the same recordset but this time with only 5 recs?
> Would it be better exiting out THE LOOP at the 5th record?
> Am I missing something here?

It is better to modify the query before it is run, rather than run a new
query, which is what your code above does.

You can modify the query before it is run by hooking into one of the many
hooks available.
Here is an example of modifying the number of posts displayed

There are other methods too.

Mike Little

More information about the wp-hackers mailing list