WordPress Thumbnail Functions

About This Index
This page is the WordPress Thumbnail Functions index. Each row links to a full guide with syntax, three examples, and FAQs.
Learn the big picture on WordPress Thumbnails. Use this page when you need one function, such as has_post_thumbnail() or the_post_thumbnail().
Check with has_post_thumbnail(), then show the image with the_post_thumbnail(). Use the get_ functions when you need the value as a string or a number.
How to Call a Thumbnail Function
Turn on thumbnails once, then check and show the image in a template.
<?php
// functions.php: turn on featured images.
add_theme_support( 'post-thumbnails' );
// single.php: check, then show.
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'large' );
} WordPress Thumbnail Functions Table
All function guides in this WordPress thumbnail series (4 tutorials). Start with has_post_thumbnail().
Check & ID
2 functionsFind out if a post has a featured image, and get its attachment ID.
| Function | Description | Tutorial |
|---|---|---|
has_post_thumbnail() | Check if a post has a featured image. Returns true or false. | Read guide |
get_post_thumbnail_id() | Get the attachment ID of the featured image. Returns 0 if none is set. | Read guide |
Display
2 functionsPrint the featured image, or return its HTML as a string.
| Function | Description | Tutorial |
|---|---|---|
the_post_thumbnail() | Print the featured image img tag, with a size and optional attributes. | Read guide |
get_the_post_thumbnail() | Return the featured image img tag as a string, to use inside your own HTML. | Read guide |
Frequently Asked Questions
Start with has_post_thumbnail()
Check for a featured image before you show it.
9 people found this page helpful
