Create Featured Section with Thumbnail In WordPress Blog
Well! If you want to create a featured section in your blog home page to show the post url with thumbnail then numbers of plugins are available that allows you to create a featured section in WordPress blog. There are many features are available in those plugins. But those plugins increase the page load time which is not good for your blog performance.
Here I’ve described an easy, simple and automated procedure to create a customize featured section with the post thumbnail for your WordPress blog. Currently, the featured section of this site also has been created by the following way.
The code for the featured section:
At first find the following line in index template (index.php) of your theme.
<?php if (have_posts()) : while (have_posts()) : the_post(); update_post_caches($posts); ?>
Add the following codes before that line:
<div id="featured"> <ul id="geekcell"> <?php $featured_posts = get_posts('numberposts=3&category=34'); foreach( $featured_posts as $post ) { $custom_image = get_post_custom_values('featured_image', $post->ID); $image = $custom_image[0] ? $custom_image[0] : get_bloginfo("template_directory")."/images/no-featured-image.jpg"; printf('<li><a href="%s"><img src="%s" alt="%s" /><div>%s »</div></a></li>', get_permalink($post->ID), $image, $post->post_title, $post->post_title); } ?> </ul> <div class="clear"></div> </div>
Understanding the code
In the fourth line of the above code replace category ID by that of your preferred category . You can see the category ID placing the mouse on the category name from your WordPress admin panel.

We have assigned a custom key ( featured_image) to fetch the image from the post. So you’ve to manually add the image source in the custom key for the post from your post editing panel, though we have discussed about an automatic procedure later in this article.

Now add some CSS rules for that featured section in the style.css template. I’ve customized the design adding the following codes in style-sheet. However, you can customize the design as you like.
#featured {
border:2px solid #3D81BB;
height:260px;
padding:4px 2px 2px;
width:627px;
background:none repeat scroll 0 0 #EEFFEE;
}
#geekcell {
list-style:none;
margin:0;
padding:0;
}
#geekcell li {
float:left;
padding:2px;
margin-left:2.5px;
border:1px solid #3D81BB;
min-height:250px;
}
.feat-title {
color:#333333;
font-weight:600;
overflow:hidden;
padding:1px 2px 0;
width:195px;
}
.feat-title:hover {
color:#CC0000;
}Now the featured section is ready and it will show the latest 3 post from the specified category.
Retrieving the thumbnail images automatically from the post
We discussed earlier that you’ll have to assign the thumbnail image source by a custom key for each featured post. But that is not handy. After searching for some plugin I nothing found such one that really can meet our requirements. So I’ve written a plugin to assign the firs post image to the custom key automatically. Download the plugin TTG Automatic Image Custom Key . After installing the plugin open the options by clicking on “TTG Automatic Image Custom Key” under “Settings” at the left side of your WordPress dashboard. Check in the option “Enable Auto Thumbnail Custom Key” and put the custom key name (here “featured_image”) in the box. Click on “Save”.

Now the first image of the post will be retrieved through the custom key, defined in the plugin option. In both of the cases the first image of your post should 200×200 according the design, I’ve used in this site. If you find any bug then let me know through the comment section.





Reader Comments
It’s very old method, specially after the inclusion of thumbnail function in WordPress. There is also other script which can generate thumbnail automatically. Anyway, still a good work.
@Arafat Hossain Piyada,
Yes the manual method is old. But you can see that I have made a plugin to make that automatically. Thanks for the information.
i always prefer manual method as plugin makes blog slow. I have tried many time with plugin.
I will always use a plugin for that , but you have done a great job. Thanks, for this tutorial :)
Good article but where is ur update? Looking forward…
We are really happy to know about your interest in TTG. But we apologize for our inconvenience. We shall be back on track soon.
nice tricks……..
i will definitely try it with my blog………
@TechGopal,
Thanks!
I think every wp blogger must use this.
@Shekhar Sahu,
Yes, featured section helps you to highlight your best posts.
Hey man!! Where’s ur update?
great share, great article, very usefull for me…thank you
I’m attracted in purchasing backlink on this domain. Please make sure to reach me personally with the asking price. Many thanks.
@Hannah: Really glad to know about your interest. But don’t mind, we do not sell our links. If we find your site useful then we’ll automatically link you.
Thanks for commenting here.
Ohh good,nice to see Google Ad on your blog again…Keep it up. I’m not doing anything right now.
Interesting plugin because it can be used in conjonction with TimThumb script (who needs a custom key for usage giving the link to the image). I will have a look to see if it works nice.
i really find registry cleaners very necessary to improve the system performance of a desktop PC “-’
Thanks for this great piece of code, I was looking for this for something like this for a while. I am having a problem though if you view my website http://www.lolonmywall.com The titles under the featured images are long so they stretch the divs, but in your image your text stacks neatly under. I was wondering how can I fix this or actually remove the title completly and just use images?
Staz: Glad that it helped you.
very useful post and a great taht u customized/developed the code of your own instead of using any plugin
But this featured Image thing..now evry premium theme comes with this feature..but its good for free themes that doesnt have this feature
ATUL
Yep. Mainly you can the code as your own requirements. Thanks for commenting here.