how to add post thumbnail on homepage in wordpress

Many times many wordpress blog and website users asked me about adding the post thumbnail on home page. Many people download the free themes from internet and they want to add the post thumbnail on homepage. In this tutorial I will tell you how to add post st thumbnail on homepage.

how to add post thumbnail on homepage in wordpress

First step open your functions.php file from wordpress theme folder and add following code in that file.


add_theme_support( 'post-thumbnails' );

Then open your index.php file and find the the_content or the_excerpt text. If you not find this text in this file then open your loop.php file from wordpress theme folder and find the_content or the_excerpt in that file. Before this tag you need to put following code in that file.


<div class="imgshadow"><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail(array(500,400), array('class' => 'imgshadowleft')); ?></a></div>

You need to specify your thumbnail size Here I chosen 500×400 size for me. Normally people choose the 150×150 or 200×200 size. After that use following css code for styling.

put following code in your style.css file.


.imgshadow{float:left; margin-right:5px}

How to set post thumbnail for home page?

Go to wordpress admin panel and create new post. you will find the “Featured Image” section bottom on right side panel. Click on “Set featured image” link.

how to add post thumbnail on homepage in wordpress
how to add post thumbnail on homepage in wordpress

Then you need to upload the image and you will find option called “use as featured image” link. Just click on that image. For help you can refer following image.

This way you can easily add the post thumbnail to your home page. For more information about wordpress thumbnail image you can read the following articles. In following you can got very detailed information about wordpress thumbnail and featured images.

Show Post Thumbnail or Featured image in WordPress RSS Feed

Add the Custom Thumbnail Size to wordpress

How to set post first image as featured image automatically

How to use the the_post_thumbnail In WordPress 3.0

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

2 thoughts on “how to add post thumbnail on homepage in wordpress”

  1. Nice article. I use this all the time. One addition: many of the newer themes (e.g. the standard 3.0 theme TwentyTen) already have theme support installed. So if you open functions.php in your favourite editor, first do a search on:
    add_theme_support( ‘post-thumbnails’ );
    to see if this is already included. If not, then add the line.

    Erik

Leave a Reply

Your email address will not be published.