Bird
0
0

Given this code snippet, what posts will the custom query retrieve?

medium📝 component behavior Q13 of 15
Wordpress - WordPress Query and Database
Given this code snippet, what posts will the custom query retrieve?
$args = ['author' => 5, 'posts_per_page' => 3];
$query = new WP_Query($args);
while ($query->have_posts()) {
  $query->the_post();
  echo get_the_title() . '
'; }
AThe latest 3 posts by author with ID 5
BAll posts except those by author 5
C3 random posts from any author
DPosts from author 5 but unlimited number
Step-by-Step Solution
Solution:
  1. Step 1: Analyze query arguments

    The 'author' => 5 limits posts to author ID 5, 'posts_per_page' => 3 limits to 3 posts.
  2. Step 2: Understand loop output

    The loop prints titles of these 3 posts by author 5.
  3. Final Answer:

    The latest 3 posts by author with ID 5 -> Option A
  4. Quick Check:

    Author 5 + 3 posts = The latest 3 posts by author with ID 5 [OK]
Quick Trick: Author ID and posts_per_page limit results [OK]
Common Mistakes:
  • Ignoring posts_per_page limit
  • Confusing author filter as exclusion
  • Assuming random posts without filter

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes