Bird
0
0

Which of the following is the correct syntax to get a custom field named 'author_name' for post ID 25?

easy📝 Syntax Q3 of 15
Wordpress - Custom Fields and Meta Data
Which of the following is the correct syntax to get a custom field named 'author_name' for post ID 25?
Aget_post_meta(25, 'author_name', true);
Bget_post_meta('author_name', 25, true);
Cget_post_meta(25, true, 'author_name');
Dget_post_meta(true, 25, 'author_name');
Step-by-Step Solution
Solution:
  1. Step 1: Recall get_post_meta parameter order

    It is get_post_meta(post_id, meta_key, single).
  2. Step 2: Match parameters with options

    get_post_meta(25, 'author_name', true); matches correct order and types.
  3. Final Answer:

    Correct syntax is get_post_meta(25, 'author_name', true); -> Option A
  4. Quick Check:

    Param order: ID, key, single [OK]
Quick Trick: Remember: post ID first, then key, then single [OK]
Common Mistakes:
  • Swapping post ID and meta key
  • Misplacing the boolean parameter
  • Using wrong parameter types

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes