WordPress Thumbnail Functions

Beginner
5 min read
Updated: Nov 2026
4 function guides
Function index

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().

Remember.

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.

WordPress
<?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 functions

Find out if a post has a featured image, and get its attachment ID.

FunctionDescriptionTutorial
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 functions

Print the featured image, or return its HTML as a string.

FunctionDescriptionTutorial
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

They are functions that check, get, and show the featured image (post thumbnail) of a post.
Use the_post_thumbnail() to print it, or get_the_post_thumbnail() to return the HTML as a string.
Use has_post_thumbnail(). It returns true or false.
When you need the attachment ID, for example to use wp_get_attachment_image() or wp_get_attachment_image_url().
The theme does not support it. Add add_theme_support( 'post-thumbnails' ) in functions.php.
Start with has_post_thumbnail(), then the_post_thumbnail(). These two cover most themes.

Start with has_post_thumbnail()

Check for a featured image before you show it.

has_post_thumbnail() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful