Bird
0
0

Find the mistake in this code to display a custom field:

medium📝 Debug Q7 of 15
Wordpress - Custom Fields and Meta Data
Find the mistake in this code to display a custom field:
$value = get_post_meta(20, 'subtitle');
echo $value;
AMeta key should be uppercase
BWrong post ID type
CEcho cannot print variables
DMissing third parameter to get single value
Step-by-Step Solution
Solution:
  1. Step 1: Check get_post_meta parameters

    Without third parameter, it returns an array of values.
  2. Step 2: Echoing array causes error or prints 'Array'

    To get a string, third parameter true is needed.
  3. Final Answer:

    Missing third parameter to get single value -> Option D
  4. Quick Check:

    Third param true returns string, else array [OK]
Quick Trick: Add true as third param to get string, not array [OK]
Common Mistakes:
  • Forgetting third parameter
  • Trying to echo array directly
  • Assuming meta key case matters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes