[wp-hackers] query_posts
Bill Erickson
bill.erickson at gmail.com
Wed Dec 21 15:10:39 UTC 2011
I like to use the pre_get_posts hook for any modifications to the main
query.
Here's a quick article with examples:
http://www.billerickson.net/customize-the-wordpress-query/
---
Bill Erickson
WordPress Consultant
http://www.billerickson.net
On Wed, Dec 21, 2011 at 5:34 AM, Mike Little <wordpress at zed1.com> wrote:
> 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
>
> http://codex.wordpress.org/Custom_Queries#Display_Order_and_Post_Count_Limit
>
> There are other methods too.
>
>
> Mike
> --
> Mike Little
> http://zed1.com/
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list