Bird
0
0

Why does a custom query with 'posts_per_page' set to -1 retrieve all posts matching criteria?

hard📝 Conceptual Q10 of 15
Wordpress - WordPress Query and Database
Why does a custom query with 'posts_per_page' set to -1 retrieve all posts matching criteria?
ABecause negative numbers cause an error and fallback to default
BBecause -1 is treated as zero, so no posts are returned
CBecause -1 limits posts to only the first post
DBecause -1 tells WordPress to ignore pagination and return all posts
Step-by-Step Solution
Solution:
  1. Step 1: Understand posts_per_page behavior

    Setting 'posts_per_page' to -1 is a special value that disables pagination.
  2. Step 2: Effect of -1 on query results

    This causes WordPress to return all posts matching the query without limiting the number.
  3. Final Answer:

    Because -1 tells WordPress to ignore pagination and return all posts -> Option D
  4. Quick Check:

    posts_per_page = -1 means all posts [OK]
Quick Trick: Use -1 to get all posts without limit [OK]
Common Mistakes:
  • Thinking -1 returns zero posts
  • Assuming negative numbers cause errors
  • Believing -1 limits to one post

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes