5. You want to query posts that are in the 'events' category AND have a custom field 'priority' set to 'high'. Which is the correct way to combine tax_query and meta_query to achieve this?
medium
A. Use 'relation' => 'AND' to combine tax_query and meta_query for AND behavior.
B. Nest tax_query and meta_query inside a 'relation' => 'OR' array within 'meta_query'.
C. Combine tax_query and meta_query inside a single array without 'relation'.
D. Use 'relation' => 'OR' at the top level combining tax_query and meta_query arrays.
Solution
Step 1: Understand combining queries
tax_query and meta_query are combined with AND logic by default when both are included in the query args.
Step 2: Correct structure
Simply place both 'tax_query' and 'meta_query' as keys in the main query args array; no 'relation' is needed.
Final Answer:
Combine tax_query and meta_query inside a single array without 'relation'. -> Option A
Quick Check:
tax_query + meta_query default = AND [OK]
Hint: tax_query and meta_query default to AND logic [OK]
Common Mistakes:
Adding unnecessary 'relation' => 'AND'
Nesting queries inside one another
Using 'relation' => 'OR' for AND logic
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.