[wp-hackers] limiting the number of posts

Simon Blackbourn piemanek at gmail.com
Thu Jan 30 19:12:02 UTC 2014


> 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.


More information about the wp-hackers mailing list