WordPress Featured Image

by Vincy. Last modified on July 12th, 2022.

In this WordPress tutorial, we are going to see what is featured image and how to add this to a post. Featured images are used to have a rich look and feel. They can be used to display posts like a gallery.

For adding featured image to the posts we have to let the theme to support post thumbnail feature. With the theme’s support, WordPress admin will provide options in UI to add post’s feature image.

What is Featured Image in WordPress

Featured image is also known as post thumbnails. In WordPress version 2.9 when it is introduced this feature is called as post thumbnail and later in version 3 it is known as featured image.

WordPress Theme Support for Featured Image

The WordPress function named add_theme_support() is used to let the current theme to support Featured images. The following code has to be added in a fileĀ functions.php.


Adding Post Featured Image

After enabling theme support we can see an option to add featured image for a post in its edit screen in Wp-Admin. The following image will show this administrative option.


After uploading featured images to the WordPress media library we have to set the uploaded image as a featured image or a thumbnail of the post.

WordPress Functions Show Featured Image

There are two functions in WordPress to get post’s featured image.

  • the_post_thumbnail() – It will display featured image.
  • get_the_post_thumbnail() – It will return a string containing the HTML code of the featured image.

Both of these functions accept two optional parameters, the thumbnail size, and the image tag attributes. Before invoking post thumbnail functions WordPress has_post_thumbnail() is used to ensure that there is a featured image added for the post.

Written by Vincy, a web developer with 15+ years of experience and a Masters degree in Computer Science. She specializes in building modern, lightweight websites using PHP, JavaScript, React, and related technologies. Phppot helps you in mastering web development through over a decade of publishing quality tutorials.

Leave a Reply

Your email address will not be published. Required fields are marked *

↑ Back to Top

Share this page