Bird
0
0

What will the following code output if the current post has a featured image?

medium📝 component behavior Q13 of 15
Wordpress - Content Management
What will the following code output if the current post has a featured image?
if (has_post_thumbnail()) {
  the_post_thumbnail('medium');
} else {
  echo 'No image';
}
AShows a syntax error
BDisplays 'No image' text
CDisplays the featured image in medium size
DDisplays the featured image in full size
Step-by-Step Solution
Solution:
  1. Step 1: Understand the condition

    The code checks if the post has a featured image using has_post_thumbnail().
  2. Step 2: Analyze the output when true

    If true, it calls the_post_thumbnail('medium'), which displays the image in medium size.
  3. Final Answer:

    Displays the featured image in medium size -> Option C
  4. Quick Check:

    has_post_thumbnail() true = show medium image [OK]
Quick Trick: If has_post_thumbnail() true, the_post_thumbnail() shows image [OK]
Common Mistakes:
  • Thinking it shows full size by default
  • Assuming it prints 'No image' when image exists
  • Confusing function usage causing syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes