Wordpress

Adding Featured Image Support to WordPress

Got a WordPress theme but don’t know how to add a Featured image or thumbnail option while creating a post. Or else want to get featured image support for your output of the blog i-e the homepage as well as the dashboard, then you are at the write place. WordPress by default has the featured image support and you just need to enable it through the Functions file of WordPress activated theme and then you can dedicate a certain image to any WordPress post as the Featured/thumbnail image. And you can call that image anywhere in the post with quite an ease. It means you can design an image which can suit the topic of post and then can use that as a featured image for  WordPress post.

Adding Featured Image/Thumbnail Support To WordPress:

You can easily add featured image support to WordPress template by editing the functions.php and then adding the following code into it:

if ( function_exists( 'add_theme_support' ) ) {
  add_theme_support( 'post-thumbnails' );
}

After you have added this code now you will be able to see the following box in your post creation area of the WordPress blog.

Featured Image in WordPress

 

After having this added to your post editor you can click on the “Set Featured Image” to add the featured image to your blog post.

Showing Featured Image/ Thumbnail to the Post Loop of the WordPress Blog:

Now comes the second part where you can easily show up the added featured image to the post loop of your WordPress blog at the homepage. I have already posted that how can you customize your WordPress loop, so before adding the featured image to the posts anywhere at your blog you should first read the previously posted article to get a better understanding of all the posts.

Go Edit your index.php and locate the loop of the posts in which you want the featured image to show up! You need to add the following code:

<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail(); ?></a>

After you have added the code, you will see that the featured image added to the specific post is now showing up at the right place.