what is the maximum number of post a wordpress loop can work with?
how many post can i display with ‘posts_per_page’ => -1?
ive got 1317+ post 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).
Thank you In advance
Looks like you run out of your php memory.
I can think of two options:
Try to add some memory in your php.ini. It won’t actually solve your problem, as your post amount will grow on, and you’ll run into the same issue again.
But meanwhile it can give you some time to work on real solution 🙂
The real solution, you can use WPDB object to work directly with WP DataBase.
In that way you can limit amount of posts you’re getting from DB, so you don’t need to store all objects in memory at once.
In that example I’m displaying category with lots of posts. I’m iterating over DB, getting 100 post each iteration ( using LIMIT), until I get all the posts:
Good Luck 🙂