Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a featured image in WordPress?
A featured image is a main image that represents a post or page. It often appears at the top or alongside the content to visually summarize the topic.
Click to reveal answer
beginner
How do you enable featured images support in a WordPress theme?
Add add_theme_support('post-thumbnails'); in the theme's functions.php file to enable featured images.
Click to reveal answer
beginner
Which WordPress function is used to display the featured image in a theme template?
Use the_post_thumbnail(); inside the loop to show the featured image for the current post.
Click to reveal answer
intermediate
Can you set different sizes for featured images in WordPress?
Yes, WordPress lets you define and use different image sizes. You can specify a size name in the_post_thumbnail('size-name'); to show the image in that size.
Click to reveal answer
beginner
What happens if a post does not have a featured image set?
If no featured image is set, the theme may show a default image, no image, or a placeholder depending on how it is coded.
Click to reveal answer
Which function enables featured image support in a WordPress theme?
Aadd_featured_image_support();
Benable_featured_image();
Cset_post_thumbnail();
Dadd_theme_support('post-thumbnails');
✗ Incorrect
The correct function is add_theme_support('post-thumbnails'); to enable featured images.
How do you display the featured image inside the WordPress loop?
Ashow_featured_image();
Bthe_post_thumbnail();
Cget_featured_image();
Ddisplay_post_image();
✗ Incorrect
Use the_post_thumbnail(); to display the featured image inside the loop.
What is the default size name to show the full original featured image?
A'full'
B'medium'
C'thumbnail'
D'large'
✗ Incorrect
The size name 'full' shows the original full-size image.
Where do you add the code to enable featured images in a theme?
Afunctions.php
Bheader.php
Cstyle.css
Dindex.php
✗ Incorrect
You add add_theme_support('post-thumbnails'); in the functions.php file.
If a post has no featured image, what might a theme show?
AAn error message
BThe post content twice
CA default image or placeholder
DNothing, always blank space
✗ Incorrect
Themes often show a default image or placeholder if no featured image is set.
Explain how to enable and display featured images in a WordPress theme.
Think about theme setup and template tags.
You got /3 concepts.
Describe what happens when a post does not have a featured image set and how themes handle it.
Consider fallback behavior.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of a featured image in WordPress?
easy
A. To change the font style of the post
B. To add background music to posts
C. To add a video to the sidebar
D. To add a main picture to posts or pages
Solution
Step 1: Understand the role of featured images
Featured images are used to add a main picture that represents a post or page visually.
Step 2: Compare options with this purpose
Only To add a main picture to posts or pages describes adding a main picture; others describe unrelated features.
Final Answer:
To add a main picture to posts or pages -> Option D
Quick Check:
Featured image = main picture [OK]
Hint: Featured images show main pictures for posts/pages [OK]
Common Mistakes:
Confusing featured images with videos or audio
Thinking featured images change fonts
Assuming featured images affect sidebars
2. Which WordPress function correctly checks if a post has a featured image?
easy
A. has_post_thumbnail()
B. the_post_thumbnail()
C. get_featured_image()
D. check_thumbnail()
Solution
Step 1: Identify the function to check featured image existence
WordPress uses has_post_thumbnail() to check if a post has a featured image.
Step 2: Differentiate from display functions
the_post_thumbnail() displays the image, not checks it. Other options are not valid WordPress functions.
Final Answer:
has_post_thumbnail() -> Option A
Quick Check:
Check featured image = has_post_thumbnail() [OK]
Hint: Use has_post_thumbnail() to check existence [OK]
Common Mistakes:
Using the_post_thumbnail() to check instead of display
Assuming get_featured_image() exists
Confusing function names
3. What will the following code output if the current post has a featured image?
The code checks if the post has a featured image using has_post_thumbnail().
Step 2: Analyze the output when true
If true, it calls the_post_thumbnail('medium'), which displays the image in medium size.
Final Answer:
Displays the featured image in medium size -> Option C
Quick Check:
has_post_thumbnail() true = show medium image [OK]
Hint: 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
4. Identify the error in this code snippet that tries to display a featured image:
if (has_post_thumbnail) {
the_post_thumbnail();
}
medium
A. Missing semicolon after the_post_thumbnail()
B. Missing parentheses after has_post_thumbnail
C. No error, code is correct
D. the_post_thumbnail() should have an argument
Solution
Step 1: Check function usage
has_post_thumbnail is a function and must be called with parentheses ().
Step 2: Verify other parts
the_post_thumbnail() can be called without arguments; the semicolon is present after it.
Final Answer:
Missing parentheses after has_post_thumbnail -> Option B
Quick Check:
Function calls need () [OK]
Hint: Always add () when calling functions [OK]
Common Mistakes:
Forgetting parentheses on function calls
Thinking arguments are always required
Assuming semicolons are mandatory in PHP
5. You want to show a featured image only if it exists, otherwise show a default image located at /images/default.jpg. Which code snippet correctly does this?
hard
A. if (has_post_thumbnail()) {
the_post_thumbnail();
} else {
echo '';
}
B. the_post_thumbnail() ?: '';
C. if (the_post_thumbnail()) {
the_post_thumbnail();
} else {
echo '';
}
D. has_post_thumbnail() ? the_post_thumbnail('/images/default.jpg') : '';
Solution
Step 1: Check condition for featured image existence
Use has_post_thumbnail() to check if the post has a featured image.
Step 2: Display featured image or default image
If true, display with the_post_thumbnail(). Otherwise, echo an <img> tag with the default image path.
Final Answer:
if (has_post_thumbnail()) {
the_post_thumbnail();
} else {
echo '<img src="/images/default.jpg" alt="Default">';
} -> Option A
Quick Check:
Check existence, show image or default [OK]
Hint: Use has_post_thumbnail() with if-else for fallback image [OK]
Common Mistakes:
Using the_post_thumbnail() in condition instead of has_post_thumbnail()
Passing image path as argument to the_post_thumbnail() incorrectly