Bird
0
0

What is wrong with this query?

medium📝 Debug Q7 of 15
Wordpress - WordPress Query and Database
What is wrong with this query?
$args = array('meta_query' => array('key' => 'color', 'value' => 'blue'));
$query = new WP_Query($args);
AMissing 'posts_per_page' parameter
Bmeta_query must be an array of arrays
CThe key 'color' is invalid
Dmeta_query cannot filter by 'value'
Step-by-Step Solution
Solution:
  1. Step 1: Understand meta_query structure

    meta_query expects an array of arrays, each with keys like 'key' and 'value'.
  2. Step 2: Identify the error

    The given meta_query is a single array, not wrapped inside another array.
  3. Final Answer:

    meta_query must be an array of arrays -> Option B
  4. Quick Check:

    meta_query = array of arrays [OK]
Quick Trick: Wrap meta_query conditions inside an array [OK]
Common Mistakes:
  • Passing single array instead of array of arrays
  • Assuming key names are invalid
  • Thinking posts_per_page is mandatory

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes