Bird
0
0

Identify the error in this WP_Query usage:

medium📝 Debug Q6 of 15
Wordpress - WordPress Query and Database
Identify the error in this WP_Query usage:
$query = new WP_Query('posts_per_page' => 10, 'category_name' => 'news');
AArguments should be passed as an array
BUse 'cat' instead of 'category_name'
CMissing 'new' keyword
Dposts_per_page should be a string
Step-by-Step Solution
Solution:
  1. Step 1: Check argument format for WP_Query

    Arguments must be passed as a single array, not as separate parameters.
  2. Step 2: Identify the error in given code

    Code passes arguments without array(), causing syntax error.
  3. Final Answer:

    Arguments should be passed as an array -> Option A
  4. Quick Check:

    WP_Query args must be array [OK]
Quick Trick: Always wrap WP_Query arguments in an array [OK]
Common Mistakes:
  • Passing multiple arguments without array()
  • Confusing 'cat' and 'category_name' usage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes