Bird
0
0

Which of the following is true about this query code?

medium📝 Debug Q6 of 15
Wordpress - WordPress Query and Database
Which of the following is true about this query code?
$args = ['post_type' => 'post', 'meta_key' => 'color', 'meta_value' => 'red', 'meta_compare' => '='];
$query = new WP_Query($args);
Apost_type 'post' is invalid
Bmeta_compare can be used at the top level for simple meta queries
Cmeta_key cannot be used with meta_value
DWP_Query does not accept arrays as arguments
Step-by-Step Solution
Solution:
  1. Step 1: Review meta query syntax

    For simple meta queries, top-level keys like meta_key, meta_value, and meta_compare are supported and converted internally to meta_query.
  2. Step 2: Check other options

    'post_type' 'post' is valid; meta_key and meta_value can be used together; WP_Query accepts arrays.
  3. Final Answer:

    meta_compare can be used at the top level for simple meta queries -> Option B
  4. Quick Check:

    Top-level meta_compare valid for simple queries [OK]
Quick Trick: Top-level meta_key/meta_value/meta_compare OK for single condition [OK]
Common Mistakes:
  • Thinking post_type 'post' is invalid
  • Believing meta_key cannot be used with meta_value
  • Thinking WP_Query does not accept arrays

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes