Discussion:
limiting the number of posts
Haluk Karamete
2014-01-30 18:55:40 UTC
Permalink
posts_per_page does not have anything to do with the LIMIT phrase of mysql.

What query argument corresponds to the LIMIT?

In other words, I'd like WordPress query to return only 3 posts max, (even
though there could be thousands that match that query. )

Now knowing any better, I'm thinking, forcing WPQuery to return only as
much as what I need is more efficient that getting them all. Hence the need
for a LIMIT. Please correct if that thinking is also not correct.
Simon Blackbourn
2014-01-30 19:12:02 UTC
Permalink
Post by Haluk Karamete
posts_per_page does not have anything to do with the LIMIT phrase of mysql.
What query argument corresponds to the LIMIT?
In other words, I'd like WordPress query to return only 3 posts max, (even
though there could be thousands that match that query. )
I think you've got it wrong: if you pass a value of 3 as the posts_per_page
argument into get_posts or a new WP_Query and inspect the query that is
run, it will show "LIMIT 0, 3".

Try the Query Monitor plugin (http://wordpress.org/plugins/query-monitor),
it outputs nicely formatted SQL of all your database queries.
Haluk Karamete
2014-01-30 19:36:57 UTC
Permalink
Simon, you are absolutely right.
I got confused between the numberposts, number_of_posts, showposts,
posts_per_page, foundposts. I definitely overlooked.
Thank you for nailing it for me.
Post by Haluk Karamete
Post by Haluk Karamete
posts_per_page does not have anything to do with the LIMIT phrase of
mysql.
Post by Haluk Karamete
What query argument corresponds to the LIMIT?
In other words, I'd like WordPress query to return only 3 posts max,
(even
Post by Haluk Karamete
though there could be thousands that match that query. )
I think you've got it wrong: if you pass a value of 3 as the posts_per_page
argument into get_posts or a new WP_Query and inspect the query that is
run, it will show "LIMIT 0, 3".
Try the Query Monitor plugin (http://wordpress.org/plugins/query-monitor),
it outputs nicely formatted SQL of all your database queries.
_______________________________________________
wp-hackers mailing list
http://lists.automattic.com/mailman/listinfo/wp-hackers
Continue reading on narkive:
Loading...