What is the maximum number of posts a Wordpress loop can work with?

How many posts can I display with 'posts_per_page' => -1?

I've got 50,000+ pages and I want to sort through them, but I just get a blank page whenever I try and do anything to more than 10,000 pages ('posts_per_page' => 10000).

  • 1
    enable debugging to see error messages. you are likely running out of memory. – Milo Jun 18 '14 at 19:35

There is no inherent technical limitation to how many posts can WP loop query. However there is always resources (CPU and memory) ceiling of specific server and configuration.

  1. If you are leaking/eating memory in any way (for example adding up some results with every post iteration) it will get exhausted quickly.
  2. WP query class (wpdb) drags all of the results into memory. For super large results sets you might need to switch to iterating via lower level MySQL access functions (WP backup plugins tend to work in that way).

There is no limit for that.

Set the wp memory limit to a higher value then you will be ok.But it will still be super slow.

You better use transient API to cache the result if you want to use this list next time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.