Home » Functions » the_post_thumbnail

The the_post_thumbnail function is a powerful tool in WordPress that allows you to display the featured image or post thumbnail of a specific post or page. It retrieves and displays the image that has been set as the featured image for the current post within the WordPress loop.

The featured image is an essential component of a WordPress website as it represents the main visual element associated with a post or page. It provides a way to showcase an eye-catching image that can grab the attention of your visitors and enhance the overall aesthetic appeal of your content.

To use the the_post_thumbnail function, you need to ensure that you have set a featured image for the post you are working with. Once you’ve done that, you can simply call the function within the WordPress loop to display the image.

Here’s an example usage code for the the_post_thumbnail function:

if (have_posts()) {
   while (have_posts()) {

      // Display the post thumbnail

In the above example, we first check if there are any posts available using the have_posts function. Then, within the loop, we call the the_post function to set up the data for the current post. Finally, we use the_post_thumbnail function to display the featured image associated with that post.

Remember that you can customize the way the thumbnail is displayed by passing in various arguments to the the_post_thumbnail function. These arguments allow you to control the size, alignment, and other attributes of the image. You can refer to the official WordPress documentation for a comprehensive list of available arguments and their usage.

So, make the most out of the the_post_thumbnail function to effortlessly showcase captivating images and enhance the visual appeal of your WordPress website!

Learn More on

Register an account to save your snippets or go Pro to get more features.