WordPress Black Friday & Cyber Monday Deals 2021!

How to Add More Than One Featured Image in Your Post

Learn how you can use the Multipe Post Thumbnails plugin to add more than one featured image (post thumbnail) to your WordPress posts/pages or custom post types.

Add secondary featured image

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:

  1. Download and install the Multiple Post Thumbnails plugin.
  2. 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’
    )
    );[/php]
  3. 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:
    [php]
    add_image_size(‘post-secondary-image-thumbnail’, 250, 150);
    [/php]
  4. In order to display the secondary image in your theme, you need to insert the following code in your post.php template file:
    [php]if (class_exists(‘MultiPostThumbnails’)
    && 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.
    [php]
    array(‘class’=>”,’title’=>”,’alt’=>”)
    [/php]

  5. 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.

Jean Galea
Jean Galea
Jean Galea is an investor, entrepreneur, and blogger. He is the founder of WP Mayor, the plugins WP RSS Aggregator and Spotlight, as well as the Mastermind.fm podcast. His personal blog can be found at jeangalea.com.

Consider sharing this post so others can find it:

Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on telegram
Share on whatsapp
Share on pocket
Share on email

Join thousands of people receiving real-world, genuine evaluations of WordPress products and services just like this one every week.

Our Sponsors
Solid Affiliate
Contents

11 Responses

  1. I think this plugin would be great, but it seems to not work with WordPress 3.2.1. After following the instructions above precisely, I’m getting the thumbnail support in the admin, however it’s not showing up on the template. I’ve checked multiple support threads on the forums and have followed support instructions on the plugin page. Is there something I’m missing?

    Thanks,
    JC

    1. Hi James I have it working on sites with the latest WP installation, so I guess it’s something on your end. Maybe try to copy and paste the code they show in their support page, and use a clean installation, see if that works. If it still doesn’t I would post your code in the WordPress support forum so the plugin devs can have a look at it.

  2. Hi Jean!

    The same problem its happen in here.
    Do you can post a link with the demo of this in use?

    Thanks!

  3. HI, nice tip – do you know of any gallery / slider plugin that supports this? Thanks!

  4. Hello Jean, how would you make the code conditional. for example, if there is no secondary image selected, then display this default image

  5. Pingback: Favoriti | Daniele Milana
  6. Hi Jean! Thank you for this wonderful trick. I think WordPress is the best platform for any type of website, but using too many plugins can affect badly on SEO results of the site.

  7. Hi Jean! I hope you are doing well.
    Thank you for this wonderful trick. I think WordPress is the best platform for any type of website, but using too many plugins can affect badly on SEO results of the site.

Leave a Reply

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

The Beginner’s Handbook
From an introduction on how WordPress works to our recommendations on products and services.
👋 Hey there! We're Gaby and Mark
Every week we share tutorials and genuine reviews of WordPress products and services in our newsletter.
Thousands of people read it!
We’d love for you to join.
We’d love for you to join. Here’s what you’ll be getting:

A single weekly email directly to your inbox.