The ‘Featured Image’ functionality introduced in WordPress 2.9 has been a real lifesaver, but what happens when you need to add more than one featured image, or post thumbnail as they are commonly known, to your post?
Enter Multiple Post Thumbnails, a very handy plugin that enables you to do just that. Here are the steps to add an extra featured image (post thumbnail) to your posts:
- Download and install the Multiple Post Thumbnails plugin.
- Open up your functions.php file, and add the following code:
[php]/* Add secondary thumbnail (featured image) in posts */
$thumb = new MultiPostThumbnails(array(
‘label’ => ‘Secondary Image’,
‘id’ => ‘secondary-image’,
‘post_type’ => ‘post’
- It is also a good idea to add a custom thumbnail size so the new featured image will get resized automatically, again in your functions.php file you can enter the following:
add_image_size(‘post-secondary-image-thumbnail’, 250, 150);
- In order to display the secondary image in your theme, you need to insert the following code in your post.php template file:
&& MultiPostThumbnails::has_post_thumbnail(‘post’, ‘secondary-image’)) :
MultiPostThumbnails::the_post_thumbnail(‘post’, ‘secondary-image’, NULL, ‘post-secondary-image-thumbnail’); endif;[/php]
You can also pass a parameter with arguments such as the class or title, just insert it as the last parameter in the line above. e.g.
- On the admin side you will see a new meta box labeled ‘Secondary Image’, just below the ‘Featured Image’ box. Use it to add your secondary post thumbnail just as you use the ‘Featured Image’ box.
So yes, thanks to this wonderful plugin, it is now possible to use more than one Post Thumbnail in WP 2.9 and above.