Bird
0
0

What will the following code output if the post with ID 10 has two meta values 'red' and 'blue' for the key 'color'?

medium📝 Predict Output Q4 of 15
Wordpress - Custom Fields and Meta Data
What will the following code output if the post with ID 10 has two meta values 'red' and 'blue' for the key 'color'?
print_r(get_post_meta(10, 'color', false));
AArray ( [0] => red [1] => blue )
Bred
Cblue
DArray ( [0] => blue )
Step-by-Step Solution
Solution:
  1. Step 1: Understand get_post_meta() with third parameter false

    It returns all meta values for the key as an array.
  2. Step 2: Check the meta values for 'color'

    There are two values: 'red' and 'blue', so both appear in the array.
  3. Final Answer:

    Array ( [0] => red [1] => blue ) -> Option A
  4. Quick Check:

    Third parameter false returns all values as array [OK]
Quick Trick: Use false to get all meta values as array [OK]
Common Mistakes:
  • Expecting a single string
  • Confusing true and false parameter

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes