Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
Recommended
WordPress Plugins
View all Guides

How to Add Featured Images or Post Thumbnails in WordPress

Last updated on by
Follow WPBeginner on YouTube
How to Add Featured Images or Post Thumbnails in WordPress

Featured images also known as post thumbnails are a popular feature in WordPress themes. Today most WordPress photography themes, restaurant themes, church themes, and other types of themes have built-in support for post thumbnails. In this article we will show you how to add featured images or post thumbnails in WordPress.

You might be thinking why are we using featured image and post thumbnail interchangeably. Well, when this feature was first introduced in WordPress 2.9, it was called post thumbnails. However, in the next version it was renamed to featured image.

Beginners Guide to Featured Images in WordPress

Featured Images or Post Thumbnails is a theme feature. Most themes such as Genesis and others support featured images by default. An easy way to figure out whether your theme supports featured images is by going to the post editor. Simply create a new post and scroll down a little to see if there is a meta box called featured images on the right hand side of the screen.

Featured Image meta box in WordPress

Adding Post Thumbnail or Featured Image in WordPress

To add a featured image in a WordPress post, simply click on “Set Featured Image” link inside the featured image meta box shown in the screenshot above. This will open the WordPress Media Uploader. You can use that to upload an image from your computer or use an existing image from your media library. Once you select the image, simply click on Set Featured Image button.

Setting a featured image in WordPress

The image will appear in the Featured Image meta box, like this:

A featured image added in a WordPress post

It is important to note that the image may appear a little bit differently in your theme. It all depends on how your theme handles featured images. Some magazine themes use smaller thumbnails along side post summaries on the main page, and a larger version on the single post view. Depending on settings defined by your theme developer, your featured image will automatically appear with your posts. However, if you want to change the way your theme handles featured images and post thumbnails then continue reading.

Note: Everything below this will require coding knowledge.

Theme Developers Guide to Featured Image and Post Thumbnails in WordPress

Even though featured image is a popular feature supported by a large number of themes, it is still possible that you might be using a theme that does not support featured images. In that case, you can add featured image support to your theme. If you are comfortable editing theme files and know your way around a little CSS, then you can do it yourself.

To add featured image support in a WordPress theme, you need to add this line of code in your theme’s functions.php file:

add_theme_support( 'post-thumbnails' );

This code will enable featured image support for posts and pages. You can now go to posts or pages, and you will see featured image option enabled. However, when you set a featured image it will not automatically display in your WordPress theme. To display featured images in your theme, you need to edit your templates and add this line of code where you want to display the featured image:

<?php the_post_thumbnail(); ?>

The files you add the above code in will vary based on your theme. You will want to add the code inside your post loop.

The above code is the basic function that you need to add featured image support and display featured images in your theme. To set image size for featured images you upload, you need to add this line of code to your functions.php file.

set_post_thumbnail_size( 50, 50);

The parameters for set_post_thumbnail_size are in this order: width, height.

You can also set additional image sizes to use with the_post_thumbnail() function. For example:

// Image size for single posts
add_image_size( 'single-post-thumbnail', 590, 180 );

In this example we have added a new image size called single-post-thumbnail with 590px with and 180px height. To use this image size in our theme, we will still need to add it in the appropriate theme file. Checkout our guide on adding additional image sizes in WordPress for more details.

If you have previously uploaded featured images, but they are still appearing in some other size, then you need to regenerate thumbnails and image sizes for older posts.

Below is an example of the featured image function with a specific image size.

<?php the_post_thumbnail( 'single-post-thumbnail' ); ?>

This is broken down version of the full functionality. You can further extend the functionality of featured images. For example, you can set a default fallback image for post thumbnails, display featured images with captions, or even add multiple post thumbnails or featured images.

We hope that this article helped you learn how to add featured images or post thumbnails in WordPress. If you have any questions or suggestions, then please let us know by leaving a comment below.


Editorial Staff at WPBeginner is a team of WordPress lovers led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »
  • http://www.wpbeginner.com/ WPBeginner Staff

    Please make sure that there is no space after the last command at the end of your functions.php file. Alternately, you can also create a site-specific plugin and paste your code there.

  • Saurabh Mathur

    My wordpress theme is wildfire and the featured image size and post featured thumbnail size are different. But on the slider, the featured image is not showing up properly and appears to be blown out of proportion. How can I make sure that when I upload the featured image, it displays correctly in slider and also in the post featured thumbnail according to the respective sizes.

  • Gemma

    Hi,

    I have tried putting this code into my functions file in lots of different spots (top, bottom, middle, etc) and it still doesn’t seem to work.

    Can you suggest any other kinds of troubleshooting? I really want to be able to do excerpts with featured images, which I know is supposed to be a function of the theme I am using.

    Help! This stuff makes me (a non-techie) go crazy!! Thank you :)

  • Sajjadur Rahman

    I start a wordPress Theme Customization, I use featured image various post in my theme,In a page “contact Us” I want to add image. I can add statically image under a div in this page.But i wan to add featured image in this div / In this section,Which will work dynamically.Now how can i call this featured image in this div………..?????????

  • Pat MacDonald

    I have a question – where exactly within the functions.php file should the snippet “add_theme_support( ‘post-thumbnails’ );” be added?

    • http://www.wpbeginner.com/ WPBeginner Support

      At the end of functions.php file.

  • luis

    this was really nice and clear! Thanks!!! =)

  • Fl├ívio Cecilio

    Good afternoon,

    I am using the ClassiPress theme and would like to announce that when the person on the site, automatically announcement appeared on facebook.
    I am using the plugin “Facebook Auto Publish” and it works well but does not put the photo.

    How can I make the images of the ads, only the first is great, appear on facebook?

    thank you!

  • Bojan

    Tnx for the article.

    I have a problem here, since if I click “New Post”, there is not Featured Image option. It appears only if I click edit on an allready published post.
    But the problem is, that once it is published, it is allready been posted to my FB, and if I edit it then, it wont get updated on FB.

    Any solution?

    • http://www.wpbeginner.com/ WPBeginner Support

      Click on New Post, when the post editor opens, click on “Screen Options” link on the top right corner of the screen. This will open a fly-down menu. You will see a checkbox next to featured images. Make sure Featured images is checked.

  • Nate Otaba

    i using “transcript wordpress theme” and i’m having difficulties having thumbnails on home page, you can only see pics when u click on a post. i have installed “regenerate thumbnail” plugin and regenerated the thumbnails and it didn’t work… Pls help…

    • http://www.wpbeginner.com/ WPBeginner Support

      Please contact your theme support

  • Nalin

    Hi, I used the featured images option. However in my blog roll, the image is on top of the excerpt. I want the excerpt to be to the side of the featured image. How do i do this?
    Thanks

    • http://www.wpbeginner.com/ WPBeginner Support

      Nalin, use CSS to set alignment for your featured images and excerpt.

  • Alexandros Gr

    I wouldn’t have done lots of things if wpbeginner hadn’t existed !!
    I am really thankful :)

    • Karol

      Guys, I used this add on: add_theme_support( ‘post-thumbnails’ ); and I ended up messing up the entire site. I don’t have a way to get back to it to delete. Help please!!!

      • http://www.wpbeginner.com/ WPBeginner Support

        Karol, you can edit it by using an FTP client, like Filezilla. Connect to your website using FTP locate the file /wp-content/themes/your-theme-name/functions.php right click and select Edit to open this file in a text editor. Find the lines you added and remove them.

  • Darlene Burke

    I have been having issues with trying to remove a featured image. When I click on the ‘remove featured image’ link in the post – nothing happens. Have you come across this before? Its causing us to have to recreate posts when we want to add a new featured image :(

    • http://www.wpbeginner.com/ WPBeginner Support

      It is possible that a WordPress plugin is causing the problem. Try deactivating your plugins one by one, after deactivating each plugin go back to a post and try to remove a featured image. Repeat this until you find the plugin causing the problem. Let us know if this resolves the issue.

  • Nishanth

    I have been using wordpress theme for my website over a month. All of a sudden now when I am uploading featured image, it is uploading but the image dimensions are not displayed in the thumbnail which shows up in Media Library, this means the post will not display the featured image. And when I click “Edit Image” next to the thumbnail, I get an error message “Image data does not exist. Please re-upload the image.” I am really frustrated because of this error, I am nto able to post new articles as I am not able to upload new images, already uploaded images works. I have searched a lot and have done all troubleshooting. Is have already contacted theme support, they are telling, its hosting issue and they should be able to resolve. I am not sure what is causing this issue. I have already emailed them and waiting for reply. Any idea why this is happening, it was working fine till now.

    Thanks any suggestions will be very much helpful.

  • TY

    Is there a way to bulk remove featured image from multiple posts? Currently the way to unset featured image is to remove it via the post edit page individually.

    • http://www.wpbeginner.com/ WPBeginner Support

      Today we published how to bulk remove featured images from posts in WordPress, we hope this answers your question.

  • Maria

    Hi, on my food blog http://www.reallifedinner I have been trying to figure out how to have the featured image show up in my category archives (like my recipe index) with out having them show up in the top corner of each post. I have turned off the display right now because it looks so stupid to have the tiny thumbnail above the larger post image. Can you help me? Is there a way I can get the one on the post to disappear without getting rid of the one in the archives?

    • http://www.wpbeginner.com/ WPBeginner Support

      You need to create a new image size for example category-archive-thumbnail. Then you need to use in your category templates. Also make sure that you not inserting the featured image inside your individual posts. You just need to set the featured image and let your theme handle the display of featured image on single post view and category archives.

  • PaulJoe

    This article helped me a lot in adding images to my WordPress blog. thank you so much

  • Nathmie

    Hi

    I have a problem which I cannot solve and still googling on this topic and hope you can advise.

    I have around 5000 custom posts, all I want to do is assign X amount of posts to a featured image, i.e. bulk assign featured image to X amount of posts.

    Can you please help me?

  • kyle

    i enterd the code above and it crashed my website – white screen of death – now i can;t get in anywhere. .. i read your page on how to fix the white screen, butnone of it worked… i just need to get into the editor theme and remove your code that i entered – any idea how to do that>?

    • http://www.wpbeginner.com/ WPBeginner Support

      you can use an FTP client like Filezilla to access your site. Then go to the file you last edited. Download that file and open it in a text editor like notepad or WordPad. Remove the lines you last edited and upload the file back using FTP.

  • Nancy ZIller

    Suddenly I can’t post images in blog. Here is what is happening:
    New Post>Add Media>Now Im at the Insert Media but it only lets my use the Upload option, the Media Library option is dead.>SO ok I’ll upload the image, it looks like it uploads, and then I get a Error Message that says, ” Error _DSC6096WEB.jpg An error occurred in the upload. Please try again later. ”
    So now I can’t insert an image in my post. However, If I hit the back arrow to my Dashboard and click on MEDIA>Library the image that had the error is there! So then I click the small box next to the image and hit view. and it shows it on my blog page as a tiny image, now I either go back OR I have the option to EDIT, I see the image but it won’t let me post the image, I have a choice of UPDATE or DELETE PERMENETLY.

    Im going in circles, any suggestions?

  • Chloe

    We’re having an issue that maybe you can help me with?
    – We add a blog post without an image
    – We check the homepage- looks fine
    – Then later we notice that an image has been randomly attached to the post
    Do you have any idea what’s causing this?
    thanks!

    • Chloe

      Also, i should say that it’s happing on the live site but we can’t seem to replicate it on the staging site which is why we suspect is has something to do with servers but not sure how to solve the problem.

      • http://www.wpbeginner.com Editorial Staff

        Seems odd. If a post is being randomly attached, then it can happen because of another plugin that maybe checks for the featured image if nothing found attaches the first image of the post as featured image.

  • justin

    when using featured images, it creates the thumbnail successfully, but also posts the larger ‘featured image’ above the posts, how do you remove this double post?

    i want my post excerpt to have a thumbnail, 200 words and a ‘read more’ button ….
    i want my full post to have the full sized photo and all the text

    why is this so hard? what am i missing? why are thumbnails tied to featured (above the fold) images??

    • http://www.wpbeginner.com Editorial Staff

      It sounds like an issue with your theme.

      • justin

        wordpress 2012 theme is what i’m using. only minor cosmetic changes to it. nothing structural.

        any ideas? i could really use some help!

        thanks very much for your response! appreciate it!

        • Martin

          Justin, did you ever fix this? The exact same thing is happening to me. I want to move to a responsive them (awethemes reactor) which adds the thumb on the posts/blog page AND in the post. Been chasing my tail on this for hours!

        • http://www.wpbeginner.com/ WPBeginner Support

          @Justin and Martin:

          Twenty Twelve displays featured image above the post content. You are not supposed to insert a featured image inside the post. You just need to set it as featured image. A lot of users make this mistake and not only they set the featured image they also insert it into the post. This way the image appears twice on the site in different sizes. Once as featured image and once as part of the post content.

          A featured image does not necessarily have to be a thumbnail or a smaller size. For example, twenty twelve and twenty thirteen display large images as featured images by default.

          So what you need to do is to create a new image size. Then remove the tag <?php the_post_thumbnail(); ?> and use <?php the_post_thumbnail(‘your-thumbnail-size’); ?> where ever your want the thumbnail to appear.

          Hope this resolves the issue you guys are having.

  • Aiza Khan

    I have a problem with my wordpress blog that the images urls are appearing like this
    http://www.pakistanimodels.pk/wp-content/uploads/2013/06/Syra-Yousuf-Wedding-Pics-Shehroz-Sabzwari-29.jpg?487874

    After the .jpg why this ?487874 is appearing. Due to this my images are not indexing in google.

    • http://www.wpbeginner.com Editorial Staff

      Its a setting in W3 Total Cache that is causing the issue.

      • Aiza Khan

        Can you tell me how to solve this problem???

  • Nathan

    That helped a lot. The coding stuff is just too complicated for me.

  • Mark

    Glad to see another good article on use of coding rather than blindly using a plugin. Keep up the great work.

  • Silvan

    Featured images only work going foward. If you haven’t set a featured image, it won’t show up.

    So is there a way to retrospectively set a featured image in bulk for each post (i.e. pick the first image in the post); without having to do it manually?

    • http://www.wpbeginner.com Editorial Staff

      Sure there is. In our article’s last paragraph, we have mentioned a way to set a fallback for featured images.

    • Tarique Sani

      There is a plugin to do precisely what you want, loop thru the old posts pick up first image and set it as featured.

      http://wordpress.org/plugins/auto-post-thumbnail/ [link modified to point to plugin page directly]

      Hope that helps