Bird
0
0

Given this query:

medium📝 Predict Output Q5 of 15
Wordpress - WordPress Query and Database
Given this query:
$args = array('post_type' => 'product', 'meta_key' => 'price', 'orderby' => 'meta_value_num', 'order' => 'ASC');
$query = new WP_Query($args);
What does this query do?
AFetches products ordered by numeric price ascending
BFetches posts ordered by title alphabetically
CFetches products with price meta key only
DFetches posts ordered by date descending
Step-by-Step Solution
Solution:
  1. Step 1: Identify post type and ordering

    Query targets 'product' post type and orders by meta key 'price' numerically ascending.
  2. Step 2: Exclude other options

    Ordering by title or date is not specified; meta_key and orderby control sorting by price.
  3. Final Answer:

    Fetches products ordered by numeric price ascending -> Option A
  4. Quick Check:

    orderby meta_value_num = numeric meta sorting [OK]
Quick Trick: Use meta_key and orderby meta_value_num to sort by numeric meta [OK]
Common Mistakes:
  • Assuming orderby defaults to title
  • Ignoring numeric sorting with meta_value_num
  • Confusing post_type with category

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes