posts_per_page no limit
I want to return ALL posts with
query_posts. I tried setting
posts_per_pageto a really high number, but
query_postsfreaks out and doesn't return any posts. What is the correct way to query posts without a limit?
$args = array( 'post_type' => 'post', 'cat' => '22,47,67', 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'depth' => 1, 'posts_per_page' => ? );
I've been Googling for awhile and searching the WP codex, but I just can't find a direct answer to this simple question. I believe my question is worded clearly with example code, and what my attempt was (setting a high value for the argument). I'm not a WP expert, so thats why I came here to ask the question. Even providing answers to questions that seem trivial to you are helpful in growing these Stack Exchange communities. I personally love seeing a Stack Overflow link in my search results, as opposed to a link to a crappy forum.
Also, thanks for the answer. You should post it as an answer and not a comment, so I can accept it.
I've got your point and I do appreciate your effort in *writing* the question. I also agree that non-expert questions can prove themselves valuable in this community. On the other hand too many of such questions can discourage some experts from getting involved here. It's all about some kind of balance I guess. Anyway I'm a big up-voter so I'm looking forward to your next questions :) Have a great time here on WPSE.
PS: you also want to replace `type` for `post_type` (or remove this line altogether). I will edit both the Rutwick's answer and your question to prevent somebody from copy-pasting this little mistake.
-1 is your answer! Look for
$args = array( 'post_type' => 'post', 'cat' => '22,47,67', 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'depth' => 1, 'posts_per_page' => -1 );
Important caveat: This can result in a very huge query that can bring the site down. Do this only if you are sure your database can handle it. Not in public themes or plugins.
Important caveat: This can result in a very huge query that can bring the site down. Do this only if you are **sure** your database can handle it. Not in public themes or plugins.