Bird
0
0

Consider this code snippet:

medium📝 Predict Output Q5 of 15
Wordpress - Custom Fields and Meta Data
Consider this code snippet:
update_post_meta(15, 'views', 100);
echo get_post_meta(15, 'views', true);
What will be printed?
Aviews
B100
CArray ( [0] => 100 )
Dnull
Step-by-Step Solution
Solution:
  1. Step 1: update_post_meta() sets 'views' to 100 for post 15

    This updates or adds the meta key 'views' with value 100.
  2. Step 2: get_post_meta() with true returns single value

    It fetches the single meta value '100' for 'views'.
  3. Final Answer:

    100 -> Option B
  4. Quick Check:

    Update then get returns updated value [OK]
Quick Trick: update_post_meta sets value; get_post_meta(true) returns single value [OK]
Common Mistakes:
  • Expecting array output
  • Confusing meta key with value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes