Bird
0
0

What will be the result of this query?

medium📝 Predict Output Q4 of 15
Wordpress - WordPress Query and Database
What will be the result of this query?
$query = new WP_Query(['posts_per_page' => 3, 'orderby' => 'date', 'order' => 'DESC']);

What posts will it return?
AThe 3 most recent posts ordered from newest to oldest
BThe 3 oldest posts ordered from oldest to newest
CAll posts ordered alphabetically by title
DNo posts because orderby 'date' is invalid
Step-by-Step Solution
Solution:
  1. Step 1: Analyze query parameters

    'posts_per_page' limits to 3 posts; 'orderby' is 'date'; 'order' is descending.
  2. Step 2: Understand ordering effect

    Descending order by date returns newest posts first.
  3. Final Answer:

    The 3 most recent posts ordered from newest to oldest -> Option A
  4. Quick Check:

    posts_per_page=3 and order DESC = The 3 most recent posts ordered from newest to oldest [OK]
Quick Trick: orderby 'date' with order 'DESC' gets newest posts first [OK]
Common Mistakes:
  • Confusing DESC with ascending order
  • Thinking orderby 'date' is invalid
  • Assuming it returns all posts

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes