• Home
  • About
    • Contact
  • WordPress
    • Plugins
    • Themes
    • iThemes
    • Builder
    • Tips and Tricks
  • Demos and Tutorials
    • Flexible Responsive Layouts using CSS in Builder

How to add featured image thumbnails to WordPress posts and pages, the easy way

By Ronald
Tuesday, August 17th, 2010

Since WordPress version 2.9, featured images (formerly known as “post thumbnails”) are integrated in the Write Post and Write Page panel. Not all WordPress themes make use of these fields, and a change to your template files is required.

In this post I will explain how you can add Featured Images to your posts and pages with only a modification to your functions.php file, and some basic styling using css. This is in particular useful when you have multiple Page templates, and therefore need to update several files to incorporate the featured images in each page.

This article will outline how to:

  • Enable support for featured images in your WordPress theme
  • Add a featured image to your post or page
  • Insert images as thumbnails in your post or page content
  • Style the images in your post or page content

Enable support for featured images in your WordPress theme

Before you can add and use featured images, your theme needs to be updated to enable the feature. First of all, you need WordPress 2.9 or higher. Download the latest version of WordPress and upgrade if you haven’t done so already. If you do not see the “Featured Image” section on the right bottom side of your Write Post or Write Page panel (see image here), chances are that you need to enable this.

To do so, you need to add the following code to your functions.php template file:

// Add support for Featured Images
if (function_exists('add_theme_support')) {
	add_theme_support('post-thumbnails');
	add_image_size('index-categories', 150, 150, true);
	add_image_size('page-single', 350, 350, true);
}

As you can see, in the WordPress backend, these are still referred to as Post Thumbnails. The key code here is to add_theme_support for post-thumbnails. The add_image_size lines define what dimensions the featured images will have when displayed.

The code is wrapped in a condition to only do this when the add_theme_support function exists, which should prevent any issues should someone try to implement this on a WordPress version pre WordPress 2.9.

Add a featured image to your post or page

Featured images can be attached to your post or page using the Write Post or Write Page panel. There is a section on the right bottom side where you can set a featured image. Walk through the following steps to attach the image to the post or page.

  • Click the set featured image link
  • Upload a file from your computer, or use an image from the media library
  • Wait for the image to upload, and the following screen to appear. Click the “Use as Featured Image” link
  • The featured image will now show on the Write Post or Page panel
  • Insert featured images as thumbnails in your post or page content

    Now we want to insert that featured image in our post or page. To complicate this slightly, we want to use two different dimensions. On our blog index page we want to show a small thumbnail (150px by 150px), but in the full blog post, or on a page, we like to show a larger version of that same image (say, 350px by 350px). We’ve already added code for this in the first step of this tutorial.

    WordPress uses hooks to enable developers to add actions, or add filters to any content that is to be displayed on your site. Without going into too much details, we will use the hook for the post or page content and add our featured images thumbnails to that content, without having to modify any theme template files.

    To do so, we will create a new function that will “hook into that hook, and add to the content”. Add the following code to your functions.php template file:

    function InsertFeaturedImage($content) {
    
    global $post;
    
    $original_content = $content;
    
        if ( current_theme_supports( 'post-thumbnails' ) ) {
    
            if ((is_page()) || (is_single())) {
                $content = the_post_thumbnail('page-single');
                $content .= $original_content;
                } else {
                $content = the_post_thumbnail('index-categories');
                $content .= $original_content;
            }
    
        }
        return $content;
    }
    
    add_filter( 'the_content', 'InsertFeaturedImage' );
    

    For those interested, a quick rundown on this code:

    • line 01 defines and names the function (InsertFeaturedImage)
    • line 03 makes sure we have the relevant post or page data available for this function
    • line 05 saves the content of our post or page
    • line 07 ensures that the following code is only executed if there is support for the post-thumbnail function.
    • line 09 checks to see if the content is from a single blog post or page, and if so,
      • line 10 replaces the content with the featured image (the_post_thumbnail), using the ‘page-single’ format (350px by 350px)
      • line 11 appends the saved original content of the post or page to the content with the thumbnail now inserted first
    • Line 13 and 14 do similar for blog index pages, or archive and category pages, making sure the smaller format (150px by 150px) is used
    • Line 18 will send the modified content back, just before it is displayed on your site
    • Line 21 finally will make sure that this function (InsertFeaturedImage) is executed each time before any post or page content is to be displayed

    Style the images in your post or page content

    Finally, we will style the images so that they float nicely to the left of our content, while leaving a bit of room around the image. The image classes (.attachment-page-single and .attachment-index-categories) are created automatically by WordPress, and are based on the image-sizes we defined earlier in step 1.

    Add the following code to your stylesheet style.css.

    .attachment-page-single {
        float: left;
        margin: 12px 8px 8px 0px;
    }
    
    .attachment-index-categories {
        float: left;
        margin: 12px 8px 8px 0px;
    }
    

    And that should do the trick. Feel free to leave your comments below.


    added 2011-05-23: To add theme support for post thumbnails on posts AND pages, use the following code:

    // Add support for Featured Images
    if (function_exists('add_theme_support')) {
    	add_theme_support('post-thumbnails', array( 'post', 'page' ) );
    	add_image_size('index-categories', 150, 150, true);
    	add_image_size('page-single', 350, 350, true);
    }
    
Categories : Code Snippets, Tips and Tricks, Wordpress

Comments

  1. How to add featured image thumbnails to WordPress posts and pages … | how to incorporate says:
    August 17, 2010 at 18:29

    [...] read more Related Posts:How to add featured image thumbnails to WordPress posts and pages …[WordPress] How to publish pictures on Picasa Web Albums using …How to Enable Comments on Blogger Pages | The Older GeekHow to Enable Comments on Blogger Pages | The Older GeekHow to improve the page rank of your website | SEO Tutorials [...]

    Reply
  2. wp-popular.com » Blog Archive » How to add featured image thumbnails to WordPress posts and pages, the easy way :: van Weerd says:
    August 17, 2010 at 19:24

    [...] the original post: How to add featured image thumbnails to WordPress posts and pages, the easy way :: van Weerd Tags: post-thumbnail, [...]

    Reply
  3. كازينو says:
    August 17, 2010 at 20:31

    Hi guys, tried loading this blog through Google RSS reader and got a strange error message, any ideas what could be the issue?

    Reply
  4. Tweets that mention How to add featured image thumbnails to WordPress posts and pages, the easy way :: van Weerd -- Topsy.com says:
    August 18, 2010 at 03:51

    [...] This post was mentioned on Twitter by Cory Miller and commonwealthpress, Ronald van Weerd. Ronald van Weerd said: New post: How to add featured image thumbnails to WordPress posts and pages, the easy way http://bit.ly/aNMes9 [...]

    Reply
  5. كازينو says:
    August 20, 2010 at 21:08

    Nevermind, works now!

    Reply
  6. Daniel Noll | Uncornered Market says:
    September 6, 2010 at 09:19

    Any idea if the Featured Image functionality works for (or can somehow be adjusted for) externally hosted images (e.g., from Flickr)?

    Reply
    • Ronald says:
      September 6, 2010 at 12:14

      Since the WordPress images are physically resized (so not dynamically during page load), images on a remote server can’t be used.

      Before WordPress implemented this feature in the core, timthumb was (and still is) a popular solution. It does resizing on the fly, and will save resized images in a local cache folder in your WordPress site.

      Reply
      • Daniel Noll | Uncornered Market says:
        September 8, 2010 at 12:08

        Thanks for the quick reply, Ronald. Looks like I’ll be using a combination of TimThumb and the GetTheImage plugin for now.

        Reply
  7. Essence Theme Series Get Major Updates : iThemes : Business WordPress Themes - WordPress CMS Themes - Since 2008 says:
    September 15, 2010 at 14:25

    [...] value, since they also incorporate the code that enables you to use the featured posts images (as described here) in your Essence [...]

    Reply
  8. Wordpress Blog Services - Essence Theme Series Gets Major Updates says:
    September 15, 2010 at 15:18

    [...] value, since they also incorporate the code that enables you to use the featured posts images (as described here) in your Essence [...]

    Reply
  9. Essence Theme Series Gets Major Updates | pro2go Designs Blog says:
    September 15, 2010 at 17:05

    [...] value, since they also incorporate the code that enables you to use the featured posts images (as described here) in your Essence [...]

    Reply
  10. Essence Theme Series Gets Major Updates | WordPress Toolbag says:
    September 20, 2010 at 03:28

    [...] value, since they also incorporate the code that enables you to use the featured posts images (as described here) in your Essence [...]

    Reply
  11. FlexxTheme Version 4.0 Released : iThemes : Business WordPress Themes - WordPress CMS Themes - Since 2008 says:
    September 21, 2010 at 15:38

    [...] value, since they also incorporate the code that enables you to use the featured posts images (as described here) in your [...]

    Reply
  12. FlexxTheme Version 4.0 Released | WordPress Toolbag says:
    September 21, 2010 at 16:20

    [...] value, since they also incorporate the code that enables you to use the featured posts images (as described here) in your [...]

    Reply
  13. Stuart Felkner says:
    September 28, 2010 at 21:08

    Very helpful post and easy to follow. Just completed the steps and am now able to utilize feature images. However, one quick question. How can I add padding to the image so the post text is moved further over to the right, away from the featured image?

    Thanks

    Reply
    • Ronald says:
      September 28, 2010 at 22:19

      Hi,

      you’ll have to play with the margin settings in the CSS code. The 2nd value in the list of four (8px) is the value for the right margin.

      Reply
      • Stuart Felkner says:
        September 29, 2010 at 01:19

        Thanks for the quick response. I increased the margins from 8px to 20px and no change occurred. I played with all four margin values and nothing was changed. Any advice?

        Thanks

        Reply
        • Ronald says:
          September 29, 2010 at 11:33

          Hi,

          I need to see this “in action” on your site, can you post a link?

          Reply
          • Stuart Felkner says:
            October 4, 2010 at 01:14

            Hey

            Thanks for your help. I was able to fix the margin on the page by adjusting code elsewhere. However, now my issue is that I don’t want the featured image to show up on the post-page as well. Any idea what code I can delete or adjust so that featured image appears on home page (150px by 150px) as it does now but not on the post-page?

            Thanks

          • Ronald says:
            November 25, 2010 at 14:31

            remove line 10 and 11 from the code in this paragraph

  14. Feature Image Help for Wordpress Blog | Our Social Media Generation says:
    September 28, 2010 at 21:42

    [...] for blog post page). Luckily, a fellow blogger and wordpress magician, Ronal, helped me out. In his blog post, he walks you through the process of adding the proper code so that when a feature image is [...]

    Reply
  15. John says:
    November 5, 2010 at 16:12

    Thats fine but could you please specify that after or before of which line we need to add these code mentioned by you

    Reply
    • Ronald says:
      November 7, 2010 at 21:10

      You can add the code to functions.php anywhere, just make sure you do so before the closing ?> at the end of the file. The css code should go in your themes stylesheet, it doesn’t matter where really.

      Reply
  16. Dannyb says:
    November 7, 2010 at 23:39

    Thanks for the great post! This was pretty much exactly what I’ve been looking for.

    Does anyone know how I could align the thumbnail to the left of the post title, not just the content?

    Here’s my page: http://mynocodata.com/blog/

    I’m using a custom loop.php page to display the post excerpts.

    Thanks

    Reply
    • Ronald says:
      November 7, 2010 at 23:58

      Hi,

      this article describes “the easy way”, in which the image is added to the_content. The content will be displayed (generally) after the header of the post is displayed, so you can’t use this “easy” method using the functions.php.

      You can however skip the (code in the) functions.php bit, and add

      <?php the_post_thumbnail(‘page-single’); ?>

      in your theme template file before the post title (or page title) is output.

      Reply
      • Dannyb says:
        November 8, 2010 at 00:35

        Thanks for the reply. I see your point and think I better understand it now.

        However I tried using “” directly into the template but the output image was full-size, not a thumbnail.

        But thanks for your help. I can use your method from this post until I learn more.

        Reply
        • Ronald says:
          November 8, 2010 at 01:51

          Use the css to adjust the size to your likings.

          Edit: scratch that, define the dimensions in functions.php, this section.

          Reply
  17. Brice says:
    November 14, 2010 at 15:08

    Thank you so much for sharing mate, something as simple as setting up a featured image drove me crazy… you made my day

    Reply
  18. yael says:
    November 24, 2010 at 21:37

    Hi there,

    Thanks for this. Would you happen to know why I do not have the “use as featured image” link in the upload feature image div? I’m using version 3.0. Also the size option are not there…

    Reply
    • Ronald says:
      November 25, 2010 at 14:27

      Did you add the required code to functions.php to add support for post thumbnails?

      Reply
  19. LUCKY says:
    January 9, 2011 at 20:10

    Thanks, for this article now i can add feature image for my client.

    Reply
  20. Test » Blog Archive » Fabrizio Cantinotti Photography says:
    January 14, 2011 at 17:00

    [...] Featured Image : In this section you upload the image of a thumbnail that would be used whenever the item is included in a portfolio gallery. You can learn about adding featured image here. [...]

    Reply
  21. Peter says:
    January 18, 2011 at 06:28

    Another way of achieving this is given at globinch.com . Read How to Create WordPress Thumbnail Based Post Archives
    http://www.globinch.com/2010/11/01/how-to-create-wordpress-thumbnail-based-post-archives/

    Reply
  22. Jauhari says:
    February 1, 2011 at 17:39

    Thanks I will try to implemented on my Website

    Reply
  23. Joeri says:
    February 4, 2011 at 13:39

    Wow, finally the information I needed! Thank you so much!
    One problem, I’ve copied all these codes and put them in the right files, but the images don’t automatically get the right size in the slideshow.
    How can I solve this?

    Reply
    • Ronald says:
      February 4, 2011 at 14:15

      This code will work for featured images in a single post or index/archive page. Not for a slideshow.

      Reply
  24. Bonita says:
    February 16, 2011 at 11:42

    Thank you for this!

    I have a question: Is it possible to alternate the way that the featured images display in a list of posts? For example, on the home page in the list of posts, each featured image per post is aligned left with content next to it on the right. Is it possible for me to make every second post’s featured image align right, with the text to the left?

    Please help!

    Reply
    • Ronald says:
      February 16, 2011 at 15:20

      Changing the float:left in the css to a float:right does the trick (http://www.w3schools.com/css/pr_class_float.asp). You should also adjust the margin values.

      Reply
    • Ronald says:
      February 16, 2011 at 15:28

      I now realise that you mention “change every second post”. That will require a bit of extra trickery, either in php, css or javascript (jQuery).

      Reply
  25. Amer Ghalayini says:
    February 26, 2011 at 23:29

    Thanks alot this was smooth and simple

    Reply
  26. Richard Vernetti says:
    March 24, 2011 at 17:47

    This worked well for me but my thumbnails arent displaying at 150×150 like i had hoped. what could be causing this?
    thanks,
    http://www.aw.vernetti.com/category/recipies/
    Rich

    Reply
    • Ronald says:
      March 25, 2011 at 13:52

      Make sure you have added the image size as described here: http://vanweerd.com/how-to-add-featured-image-thumbnails-to-wordpress-posts-and-pages-the-easy-way/#enable_image and refer to the correct value as described in this section: http://vanweerd.com/how-to-add-featured-image-thumbnails-to-wordpress-posts-and-pages-the-easy-way/#insert_image

      That should do the trick, unless there is something in your theme or plugins overriding this.

      Reply
  27. GM Coffi says:
    April 2, 2011 at 06:30

    This is the tutorial I’ve been looking for! well documented and easy to understand…great job.

    For some reason my thumbnail have no thumbnails…But I read in other blogs that it usually the other way around (new posts have thumbnails and old ones don’t)

    Any idea on how to fix it?

    Regards,
    GM Coffi

    Reply
    • Ronald says:
      April 2, 2011 at 09:49

      please clarify: “my thumbnail have no thumbnails”

      Reply
  28. Alex Navas says:
    April 7, 2011 at 08:21

    First of all, thank you for such a clear explanation. I was trying to figure it out but couldn’t.

    I do have one questions. I’ve followed your instruction to a T but made one change to the code to adjust the single post size to 250 x 250.

    Here’s the code directly from the functions.php file:
    if (function_exists(‘add_theme_support’)) {
    add_theme_support(‘post-thumbnails’);
    add_image_size(‘index-categories’, 150, 150, true);
    add_image_size(‘page-single’, 250, 250, true);
    }
    However, on single pages, it still shows up 350 x 350. Here’s an example: http://www.alexnavas.com/how-packaging-your-business-can-increase-your-income/

    I’m using Builder as the theme.

    Thanks for your help

    Reply
    • Ronald says:
      April 7, 2011 at 10:30

      there is other css code that is overriding the code you added (.hentry img). That leaves you no other option than to specify height and width yourself, e.g.

      img.attachment-page-single {
          float: right;
          margin: 0px 0px 10px 8px;
          height: 250px !important;
          width: 250px !important;
      }
      
      Reply
  29. Fernando says:
    April 8, 2011 at 17:41

    VERY NICE MAN! TKS!!!

    Reply
  30. Shaun says:
    April 9, 2011 at 16:46

    Thanks so much for this. I have one problem. The images are showing up on both the excerpt and the post…however, they are flush left and instead of the text lining up next to it on the right, the text is appearing below the image.

    Is there something I can do to remedy this.

    Reply
  31. shaun says:
    April 9, 2011 at 17:45

    Actually, for whatever reason the thumbnail is now left with the text to the right, but the top of the thumbnail is not alinged with the text. The text starts above the thumbnail, giving the thumbnail and awkward appearance on posts where the text is shorter.

    Is there a way to fix this?

    I input everything as you suggested, although I replaced 150, 150 for 350, 350 since I wanted the smaller size to appear on both the excerpt and the main post.

    Thanks so much for your help with this.

    Reply
    • Ronald says:
      April 9, 2011 at 23:29

      you’ll have to fiddle with the CSS code, increase the margins probably.

      Reply
  32. David says:
    May 6, 2011 at 19:18

    Thank you so much for this post, a real lifesaver!!!

    I prefer to avoid plugins at whatever cost and this worked like a charm, I had some initial trouble and had to recreated one post cause the thumbnail wouldn’t behave but now she’s under control :)

    Keep up the good work

    Reply
    • Ronald says:
      May 6, 2011 at 22:07

      thanks, glad it’s working well for you!

      Reply
      • David says:
        July 10, 2011 at 15:12

        Im adding this to another site but I don’t want the featured image to appear in the post just the excerpt, I figured if i just remove

        ‘ $content = the_post_thumbnail(‘page-single’);
        $content .= $original_content;
        } else {‘
        that it would work but it doesn’t. Can you help shed some light on this for me.
        Thanks.

        Reply
        • Ronald says:
          July 10, 2011 at 16:17

          asked and answered in the comments

          Reply
  33. Holger says:
    May 12, 2011 at 15:51

    Ronald,

    worked on first try, used manually enable instructions.
    very detailed and easy to follow.

    thanks for the quick reply via forum.

    Reply
  34. Stu Mo says:
    May 18, 2011 at 13:58

    You state featured images on posts AND pages. I’m running wordpress 3.1.1 and have featured images and have set them on POSTS but have no option to add them to or feature them on PAGES. Can you explain how I do this for PAGES (not POSTS), thanks.

    Reply
    • Ronald says:
      May 23, 2011 at 12:56

      good catch, I didn’t include the proper code to enable support for posts AND pages that in functions.php.
      I just added it to the end of the article.

      Reply
  35. ashutosh joshi says:
    May 23, 2011 at 12:20

    I can’t tell you how much this article helped my. Adding featured has highly improved look of my website. thank you very much. and keep giving such posts…

    Reply
  36. ashutosh joshi says:
    May 23, 2011 at 12:49

    featured image is not being shown when I am making manual excerpts please give me any solution sir.

    Reply
    • Ronald says:
      May 31, 2011 at 11:05

      Add the same line of code for the_excerpt in functions.php:

      add_filter( 'the_excerpt', 'InsertFeaturedImage' );
      Reply
  37. ashutosh says:
    May 29, 2011 at 00:15

    Sir I how can I show continue reading after the excerpts?
    please give reply to my questions sir..

    Reply
    • Ronald says:
      May 31, 2011 at 11:08

      add

      <a href="<?php echo get_permalink(); ?>"> Read More...</a>

      after the excerpt, and/or read the documentation here: http://codex.wordpress.org/Function_Reference/the_excerpt#Make_the_.22read_more.22_link_to_the_post

      Reply
  38. ashutosh says:
    June 8, 2011 at 09:36

    Sir I has got one other question-
    How can I link the featured image with post?

    Reply
    • Ronald says:
      June 12, 2011 at 22:39

      Hi,

      check these resources, and adapt the code accordingly

      Reply
  39. Kevin K says:
    June 12, 2011 at 06:20

    Hello, sorry I’m VERY new at this and I’m setting up my website now. When I follow your instruction. I’m getting a small icon and the large picture. You can see http://www.briefopinions.com

    Now that I’ve played with it, I think my “featured” picture is automatically being inserted into the post even though I never clicked the button “insert into post.” Any ideas?

    Reply
    • Ronald says:
      June 12, 2011 at 22:37

      Hi,

      “the easy way” in the title indeed refers to the fact that this is done automatically, which is what this article is about.

      If your theme already inserts featured images, you should not need to add additional code to do the same.

      Reply
      • Kevin K says:
        June 13, 2011 at 05:28

        Wow I got it now. I guess it was very late last night. Thanks for the help. Great tut.

        Reply
  40. Siobhan says:
    June 14, 2011 at 02:02

    Hello,

    I’m trying to figure out if it’s possible to use a rollover image as the featured image thumbnail.

    Here is a link to my site: http://siobhanmcdevitt.com/

    As you can see, all of my project thumbnails are illustrated using a blue & white color scheme. When the mouse moves over each thumbnail, I would like them to change to photographs of the projects.

    I’ve been researching how to accomplish this for a long time with no luck, so any ideas are appreciated.

    Thanks!

    Reply
  41. indika says:
    July 5, 2011 at 12:12

    Hi Ron,

    Thanks for the very useful article. is there a way i can add a different css style to the thumbnails on wordpress categories. i got this page on my site where showing posts from a category. for this page i need to give a different style.

    very much appreciated if you can help me on this.

    Reply
    • Ronald says:
      July 6, 2011 at 11:28

      You could add another condition based on category, such as is_category (http://codex.wordpress.org/Conditional_Tags#A_Category_Page) and assign a different thumbnail size. This code should go into functions.php (http://vanweerd.com/how-to-add-featured-image-thumbnails-to-wordpress-posts-and-pages-the-easy-way/#insert_image)

      Then add the required css code for that new selector (http://vanweerd.com/how-to-add-featured-image-thumbnails-to-wordpress-posts-and-pages-the-easy-way/#style_image).

      index-categories is currently used as a general selector for all posts or pages that are not single posts, but the name is irrelevant, you can name it anything you like.

      Reply
      • Haseeb says:
        July 22, 2011 at 17:01

        Hey Ronald, great article. I came across because I am having a problem in increasing my featured image size that is shown at home page with the respective post. I have a theme that has the thumbnail support by default but I have done everything to increase the size of featured image thumbnail on index page. Can you please help me out in it. I’ll be very much thankful. I don’t know codes and stuff.
        Regards

        Reply
  42. indika says:
    July 7, 2011 at 06:28

    Hi Ron,

    How can i enable different thumbnail sizes for post & pages. is there a modification i need to do your script.

    ex: post thumbnail – 200 x 200

    page thumbnail – 150 x 150

    kindly provide me some help.

    indika.

    Reply
  43. Add Featured Image to Your Theme « « Jason Flaherty Jason Flaherty says:
    July 14, 2011 at 05:41

    [...] 3+ that is super great and I wanted to add that functionality to this theme. After looking around I found the solution. I hope it helps you! [...]

    Reply
  44. Luxurytracks says:
    July 17, 2011 at 19:40

    When I load my site on to facebook or any other social network the facebook or twittter thumbnail comes up as the icon! I would like for my logo to appear as the icon..Any advice?? Thanks

    Reply
  45. anandy says:
    July 30, 2011 at 05:29

    thanks i was looking for it……………

    Reply
  46. Sarah O'Neill says:
    August 16, 2011 at 01:31

    Hi Ron,

    I recently installed a script to migrate my pixelpost blog to wordpress. It seemed to work but the thumbnails and images are not showing in the migrated posts. If I upload a new image in a post, the ‘featured image’ works. I have over 600 posts from my pixelpost blog … I have tried looking into bulk actions in the ‘Posts’ section but the option isn’t available for ‘featured posts’. I have to manually go to each migrated post and set the featured image option, show the photo I want to attach to post and resave.

    Is there any way around this then doing every manually?

    Sarah

    Reply
  47. yp says:
    August 23, 2011 at 03:31

    Could you help me fix the following:
    The images are showing up on both the excerpt and the post…however, instead of the text lining up next to it on the right, it is appearing below the images.

    Reply
    • Robyn says:
      December 8, 2011 at 06:35

      This is the same exact problem I am having!

      Reply
  48. yp says:
    August 23, 2011 at 03:41

    Nevermind, I got it to work.

    Thanks for the great article!

    Reply
  49. Zininweb says:
    August 24, 2011 at 15:24

    Great article, veryy helpful. My question is if it is possible to have more than one featured images on one page.

    Reply
    • Ronald says:
      September 7, 2011 at 00:22

      no, WordPress allows you to attach only one featured image to a post. You can of course insert images in post and page content yourself.

      Reply
  50. Raj says:
    August 25, 2011 at 13:15

    will this featured image be good for listings on google search results?

    Reply
  51. Ashutosh says:
    August 30, 2011 at 14:17

    Sir I am very thankful to you. I am just a child in the field of wordpress but your easy tips helped me a lot.
    I have totally transformed my wordpress theme.
    you can check it http://www.funnattack.com/home
    but sir I have one more question…
    I want to change the background color of read more button. will you help me please…
    Thanking you
    Ashutosh

    Reply
  52. Diogo says:
    September 5, 2011 at 16:09

    I just want to say thank you so much Ronald! Awesome tutorial!

    Reply
  53. nitin kumar says:
    September 7, 2011 at 07:26

    Thank you good stuff

    Reply
  54. Alex Navas says:
    September 12, 2011 at 16:45

    Hey Ronald, I used this again on another site and now found out that the featured image is appearing twice on my site at http://www.AwakenedPurpose.com/blog. Do you know why this could be happening? I checked the code and I’ve only placed it once from what I see.

    Thanks again for this great resource.

    Reply
    • Ronald says:
      September 12, 2011 at 17:07

      Hi Alex,

      perhaps the theme is loading the featured image by default (so you don’t need this function to do so yourself)?

      Otherwise, hard to tell from here, can you double check the code in functions.php and in index.php?

      Reply
      • JimmyLaz says:
        September 14, 2011 at 20:48

        I can confirm the featured image is appearing twice in category list view…can’t report URL because site in development but having the same issue here.

        Plug-ins installed: Regenerate Thumbnails, Auto-Hyperlink URLs and Front Slider. I doubt any of those are interfering.

        Reply
  55. Mike says:
    September 14, 2011 at 19:37

    Great article, exactly what I was looking for. However when I add the code, the thumbnail shows up twice. Any idea where that is coming from?

    Reply
    • Ronald says:
      September 14, 2011 at 20:17

      Mike, check the comment right above this one. What is the url of your site, page where this happens?

      Reply
  56. Another test | A Test Site says:
    September 16, 2011 at 19:32

    [...] Enable support for featured images in your WordPress theme [...]

    Reply
  57. Añadir soporte Imagen Destacada a temas para WordPress | Ad Astra Errans says:
    October 1, 2011 at 08:24

    [...] Vía Van Weerd. [...]

    Reply
  58. Felipe Veiga says:
    October 2, 2011 at 10:12

    Thanks for the post, it really clarified my questions. And also, thanks to Jimmy for the plugins he nominated, really usefull. Thou I am now using Ajax Thumbnail Rebuild.

    Reply
  59. Tom Durkin says:
    October 4, 2011 at 22:00

    HI really useful and easy to follow, thanks!

    One question, I use images that have all different aspect ratios so setting a width and height for every single image by default leaves some distorted.

    Is there a way that the feature image can automatically ‘crop’ rather than actually resize the image?

    This would be really useful for me

    Thanks again

    Tom

    Reply
    • Ronald says:
      October 5, 2011 at 09:16

      Hi Tom,

      glad you enjoyed the article. Check the add_images_size parameters, and change the code accordingly in your functions.php.

      Reply
  60. Mike says:
    October 11, 2011 at 01:30

    I too am getting the double thumbnail issue on both the single post page and the category page. On the category page the thumbnail appears next to each other, on single page the extra thumbnail is added at the top of the page, along with the post excerpt. On checking the source code the thumbnail and excerpt appear just after the body tag.

    Had a route around and can’t see anywhere else the thumbnails are being called. I’ve disabled the thumbnails for now, but can send both my functions and single pages if you’d like?

    Reply
  61. Rohan says:
    October 13, 2011 at 12:33

    Hey. Awesome article.

    But, I don’t know, I did something wrong while editing. :(
    1. I followed your instructions of adding the feature of “Featured Image” in the blog – That’s Done.!
    2. I tried one post and then adding one Featured Image, I posted one article. – That’s Done.!
    3. I can now see that, Featured Image is displayed on screen. :)

    But, The image is aligned at left (which is right) and text is displayed below the added image. What I want is, Featured Image on left and Text of the post should start just after the image on its right.
    Why the text is displayed just beyond the image?

    Please help me out.
    In case of any editing, please tell me, what should be done.
    Thanks a lot, in advance.

    Reply
    • Ronald says:
      October 13, 2011 at 16:45

      the css code should align the image in such a way that text sits next to it. Check your code, and if you want me to have another look, also add a link to your site.

      Reply
      • scott says:
        April 25, 2012 at 00:39

        hey ronald, i am having problems with adding featured posts. http://rugbywarfare.com/ that is the website. the image is on the left, i have altered the margins that the text is on the right ( but it is still below the image ) and it just looks horrrible. this is really frustrating

        Reply
  62. Magnus says:
    November 3, 2011 at 19:23

    Great Article!

    I managed to get the thumbnail but the text is not floating around the image even though I added the CSS as described.

    I suspect something is overwriting it?

    Could you have a look:
    http://www.magnusbogucki.com/blog

    thanks!

    Reply
  63. Magnus says:
    November 3, 2011 at 19:38

    Also, by default it seems the thumbnail picture is 366×500 whilst I set the thumbnail on my index page to 100x 100 but Googe Page speed complains and says this

    “http://magnusbogucki.com/blog/Hochzeitsfotos/morcote13.jpg is resized in HTML or CSS from 366×550 to 99×150. Serving a scaled image could save 40.1KiB”

    So my question is, how can I get around this?

    Reply
    • Ronald says:
      November 5, 2011 at 12:36

      New featured images will be resized based on the image sizes you specified. For existing media library images, use the Regenerate thumbnails plugin: http://wordpress.org/extend/plugins/regenerate-thumbnails/

      Reply
  64. Juddc says:
    November 5, 2011 at 01:17

    Hi Ron,

    Any way you know of to add a link to the Featured Image? Say I have a display image that I want to link to another website or a specific URL. Any thoughts?

    Thanks for your time,
    Judd

    Reply
    • Ronald says:
      November 5, 2011 at 12:43

      You can find examples here: http://codex.wordpress.org/Function_Reference/the_post_thumbnail

      Reply
  65. Wella Baker says:
    November 10, 2011 at 19:30

    Hi Guys,

    I hope you can help me. I am not really familiar in WordPress Codex. I have a problem about my featured image theme of each blogs. I just add blogs to my site and after that the featured image in the theme got error44. Please help me…..

    Reply
  66. Johan says:
    November 15, 2011 at 23:54

    Wow this code work likes Rocket !! So much thanks for this type of post :)

    Reply
  67. snowboardmommy says:
    November 19, 2011 at 03:24

    Thank you! This worked amazingly well … nice and straightforward too.

    Reply
  68. Triplecolourlife » How to add featured image thumbnails to WordPress posts and pages says:
    November 25, 2011 at 04:52

    [...] Add the following code to your functions.php template file: ? [...]

    Reply
  69. Daniel says:
    December 1, 2011 at 16:23

    Do you know if it’s possible to disable a featured image on a multi-page post? For example, I want the featured image to display on the first page, but then once the user visits the second page, they don’t see the featured image? (as at the moment, I’m only able to make it appear on both of them).

    Any ideas, or advice on how I could go about this? It’d be much appreciated.

    Reply
  70. Dave says:
    December 4, 2011 at 06:45

    This has help me with the exception of one problem. yp stated it above, the featured image shows up, but the excerpt text is below the image, not to the right of the image.
    I have added the css from the tutorial above, but am now stuck. Any suggestions?

    Reply
  71. Maurice says:
    December 8, 2011 at 14:29

    BRAVO MAN, JUST BRAVO!!!

    Reply
  72. Praveen says:
    January 1, 2012 at 15:04

    I face some problem in showing Thumbnail. anyway thanks for this tutorial i will sort and fix the problem out. :)

    Reply
  73. Scott Sprich says:
    January 5, 2012 at 07:27

    Ron. Your EASY instructions finally got this to work on my site. I’ve looked all day and every other explanation didn’t work for whatever reason. I did exactly what they said, but obviously you say it better.

    You saved me valuable time and made my site that much more appealing to readers.

    Thanks a bunch.

    Scott Sprich

    Reply
    • Ronald says:
      January 5, 2012 at 12:05

      glad to hear that, thanks

      Reply
  74. Daily Diigo Links 01/05/2012 | HANs on Experience says:
    January 5, 2012 at 13:32

    [...] van Weerd How to add featured image thumbnails to WordPress posts and pages, the easy way :: van Wee… [...]

    Reply
  75. Scott Sprich says:
    January 5, 2012 at 15:04

    So after further inspection I’m having some issues. On some of my posts where the featured image is a larger size it’s replacing my header image when on the page. Here’s an example: http://sprichie.com/adding-the-pin-it-button-to-ipad-bookmarks/. I used firebug to tell me some more and this is what it shows:

    On the incorrectly viewed post:

    The way it should look with my main theme’s image:

    It’s happening here as well: http://sprichie.com/2012-new-years-resolutions/

    As you can see when the original featured image I upload is of a larger size it’s replacing the header image, at least it appears to.

    These are the changes I made to the “Add support for Featured Images”.

    // Add support for Featured Images
    if (function_exists(‘add_theme_support’)) {
    add_theme_support(‘post-thumbnails’, array( ‘post’, ‘page’ ) );
    add_image_size(‘index-categories’, 250, 250, true);
    add_image_size(‘page-single’, 515, 515, true);
    }

    Just trying to give as much info as possible. Thanks Scott

    Also what comment plugin are you using?

    Reply
  76. Shivkumar says:
    January 8, 2012 at 07:47

    While going through the post simultaneously applying on my blog
    got a kindle error but your reply to others comment help me a lot
    thanx Ronald

    Reply
  77. Conferencista says:
    January 12, 2012 at 20:09

    Thank you for the code Ronald, it made the trick perfectly.

    Reply
  78. Case de lemn » postare 3 says:
    January 16, 2012 at 21:29

    [...] show a larger version of that same image (say, 350px by 350px). We’ve already added code for this in the first step of this [...]

    Reply
  79. Luv What You Do says:
    January 22, 2012 at 01:20

    How do I make a featured image in Windows Live Writer?

    Any idea how to make a Sticky Post in there too?

    Thanks!

    Reply
  80. Heather @ Family Friendly Frugality says:
    February 12, 2012 at 01:39

    This worked PERFECTLY.

    I had to remove lines 10 and 11, but once I solved the dupe image issue, it was perfect.

    You have no idea. I’ve been pulling my hair out over this. THANK YOU for such a detailed and helpful tutorial.

    Reply
  81. Ondra says:
    February 13, 2012 at 16:39

    Hello, I use this “How to…” and it works, but now I see TWO thumbnails in post. Have you any idea how can I show only one thumbnail in post? Check here: http://tomakoule.cz/zambie-mistrem-afriky/

    Reply
    • Ondra says:
      February 13, 2012 at 17:12

      Everything is OK. Fail = Related posts. Related posts now OFF and I have one picture in post.

      Reply
  82. Richard Carter says:
    February 21, 2012 at 16:53

    Thanks, just what I was after!

    Reply
  83. TRIGYY says:
    March 5, 2012 at 10:32

    nice tips. thanks for sharing the info

    Reply
  84. Danny Geraghty says:
    March 5, 2012 at 23:02

    Great post. I’m having an issue that one other user mentioned above but for some reason I cannot solve myself. I’m trying to get the thumbnail to align to the left of the title + text + meta data and not just the text itself. On Nov 7 2010 you said put this code before the title:

    I did that in content.php but for some reason the thumb still appears above the post. I’m trying to do this for my index page only using the standard twentyeleven WordPress theme.

    Do you have any suggestions?

    Reply
  85. Sue says:
    March 8, 2012 at 21:32

    I dont want the image to appear in the post,only in the excerpt,but I`m not a codes savvy.Can you direct me to a plugin that could help me with that?

    Thank you

    Reply
    • Ronald says:
      March 14, 2012 at 14:11

      instead of filtering on the_content, you could use the_excerpt

      Reply
      • BlogGirl says:
        July 27, 2012 at 17:42

        thank you for this answer! :) Was about going crazy just thinking of a solution. ;) )

        Reply
  86. Byteat.com says:
    March 14, 2012 at 01:49

    Thanks for your post but i think their is plugin more simple for the same issue
    http://wordpress.org/extend/plugins/query-posts

    Reply
  87. Jakob says:
    March 18, 2012 at 17:09

    Hey. very useful code! thanks!

    Is there a way to add the featured image above the post-title? I’m working on a thematic child theme and i’m having some trouble with this

    Reply
  88. Rob H says:
    March 29, 2012 at 02:51

    Thank you for writing such a clear post, especially giving explanations too.

    I used it exactly as it is and have no problems; in fact, thanks to your explanations I have been able to tweak styling etc. to suit my needs.

    Also, it is great not to have to use a plugin as this only slows a site down; and I for one would rather have full control over my site rather than use another plugin.

    Thanks again!

    Reply
  89. Mike says:
    March 30, 2012 at 12:37

    Thanks a lot, I have been searching for this solution for quite a few hours now :-) !

    Reply
  90. Nikita Sharma says:
    April 3, 2012 at 13:46

    This post really helped me so much.
    I enabled featured image in my wordpress theme.
    and now I also know, how to use CSS for featured image.
    thank you so much admit for this wonderful article.

    Reply
  91. Good Wordpress Resources | DGT Creative says:
    May 5, 2012 at 01:12

    [...] Adding a Featured Image: http://vanweerd.com/how-to-add-featured-image-thumbnails-to-wordpress-posts-and-pages-the-easy-way/#… [...]

    Reply
  92. CoffeeChug says:
    May 30, 2012 at 22:15

    This code works nearly perfectly, however when I do a search on the site, the results posts all have 2 thumbnails. Any suggestions?

    Reply
  93. Dachel Miqueli says:
    June 6, 2012 at 06:51

    What if you have the “Feature Image” available when Im creating pages but when I try to write a Post is not available. Any suggestions?? I tried to do the tutorial but I think Im not that smart for codes :(

    Reply
    • Dachel Miqueli says:
      June 6, 2012 at 17:49

      nevermind, I got it lol.

      Reply
  94. Surya Haris Senoaji says:
    June 14, 2012 at 02:14

    Thanks bro.. :D
    it’s work…

    Reply
  95. Vipin says:
    July 26, 2012 at 18:23

    i was looking for this since long..thanks alot ronald for this..

    Reply
  96. KAF says:
    September 9, 2012 at 01:47

    ThanX alot
    god bless you man
    it works :D
    easy & effective.

    Reply
  97. Paul says:
    October 1, 2012 at 13:16

    My theme forces the featured image into the body of the post when I only want it to appear in a designated place for the thumbnail.

    See the portfolio gallery here where it should appear…
    http://www.paulstadnyk.com/portfolio/

    and the page where it is automatically added (dont want it here)
    http://www.paulstadnyk.com/portfolio/test-7/

    Any idea on how to prevent that from occurring?

    Thanks in advance. Apologies if this is covered previously.

    Reply
  98. Andy says:
    November 22, 2012 at 21:20

    Great post! Helped me sort out the thumbnail issue. 110% useful and thanks for this.

    Reply
  99. Umar Farooq says:
    December 7, 2012 at 07:54

    Excellent Work,
    Thanks a lot

    Reply
  100. afi says:
    December 17, 2012 at 08:19

    Thank you soooooooooooo much!

    Reply
  101. Add the Featured Image Function to your WordPress Theme « Wordpress « Blog « WebPress Ottawa DALEN DESIGN says:
    January 2, 2013 at 09:09

    [...] For further instructions about styling Featuring Images to WordPress and using hooks for your theme please visit Vanweerd’s blog » [...]

    Reply
  102. arvind mishra says:
    March 25, 2013 at 13:44

    Awesome tutorial…………

    Reply
  103. Nick says:
    April 3, 2013 at 15:24

    2013 and still this guide help me do what I needed to! Thanks a lot :)

    Reply
  104. Jack Logan says:
    April 19, 2013 at 09:45

    Thank you very much!
    Very useful article. I learned something else.
    Best regards,
    Jack

    Reply
  105. .com says:
    May 1, 2013 at 10:29

    I’m new to this entire writing a blog thing and putting feedback for backlinks. I see tons of individuals are just adding in comments like “wonderful article” or “superior post”. Isn’t
    this spam? Why do a lot of websites allow this stuff to be published?
    Is there not an automatic get rid of function for posts?

    Reply

Leave a Reply

Click here to cancel reply.