How To Add Featured Image Support To A WordPress Theme

4 Comments

If you look beside this post, you will see an icon or image of the WordPress badge. This was added to the post so it displays as a ‘Featured Image’ or Post Thumbnail and it can be set so it clicks through to the blog post.

Adding Featured Image support to a WordPress Theme is a pretty simple process and aside from the styling, requires only a bit of cut and paste.

You are going to edit 3 files:

1. functions.php

2. index.php (or loop.php)

3. style.css

Open up your functions.php file and paste this in:

// add featured image support
add_theme_support( 'post-thumbnails' );

You need to make sure it is between <?php and ?> for it to add support for featured images, or post-thumbnails as they are called.
Save the file and open up your index.php (or loop.php for child themes) file. Add this code, wherever you want it to appear in the loop:

<!-- display featured images -->
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>

Save the file and style it by opening your style.css and adding something like this:

/* ==== featured image ==== */ 
.attachment-post-thumbnail { 
width:120px;
height:120px;
margin-right: 10px;
margin-bottom: 10px;
float:left;
}

Once you save this file, log in to your WordPress admin panel and you will see a new palette on the sidebar.
set featured image

From here you can select your image and pick the use as featured image option.

General, WordPress , , , ,


4 Comments

  1. Nele

    Hiya, Amazing Blog article! I have just retweeted this post to my readers.

  2. leon

    wow. thank you very much. it helped me create specific gif banners per post and page.

    • Stuart

      You are welcome – good idea too!

  3. ali

    really bro i was searching for this and it was easy thank you very much

It's good to talk!

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

Please answer before submitting form * Time limit is exhausted. Please reload CAPTCHA.