Beginner's Guide for WordPress - Start your WordPress Blog in minutes.
Choosing the Best
WordPress Hosting
How to Easily
Install WordPress
WordPress Plugins
View all Guides

How to Add Multiple Post Thumbnails / Featured Images in WordPress

Last updated on by
Special WordPress Hosting offer for WPBeginner Readers
How to Add Multiple Post Thumbnails / Featured Images in WordPress

Recently one of our readers asked if there was a way to add multiple post thumbnails or featured images in a WordPress post. By default, most WordPress themes come with built-in support for featured images which makes adding post thumbnails really simple. However when working on custom projects, you might need to add a second featured image to a post. In this article we will show you how to add multiple post thumbnails / featured images in WordPress.

First thing you need to do is install and activate the Multiple Post Thumbnails plugin. After activating the plugin, you need to add the following code in your theme’s functions.php file. You can add it anywhere in the file as long as you are doing it right. Read our guide on how to paste snippets from the web.

if (class_exists('MultiPostThumbnails')) {

new MultiPostThumbnails(array(
'label' => 'Secondary Image',
'id' => 'secondary-image',
'post_type' => 'post'
 ) );


Once you add that, you can now add a secondary featured image to your post. All you have to do is Edit an existing post or create a new post. You should see a secondary featured image meta box right after the featured image box in WordPress post edit area.

Featured and secondary featured image in post edit area

Even though you can add a secondary featured image in your WordPress admin, it will not display on your site until you configure your theme. All you need to do is add the following code inside your post loop where you want to display it. This could be in your single.php (for single posts), archive.php (only for archive pages), etc.


if (class_exists('MultiPostThumbnails')) : 

MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image');



Once you do that, you are done. Your theme is now ready to display multiple featured images. This is how it looked like when we tested it:

Adding Multiple Post Thumbnails or Featured Images in WordPress

You can repeat this process to add as many featured images as needed. You can also extend the support to other custom post types instead of just posts.

Adding New Thumbnail Sizes

If for some reason you need to change the thumbnail size for the secondary featured image, then you can do so by creating additional image size in WordPress. Don’t forget to regenerate thumbnails or new image sizes. After this you can call the new image size in your multiple post thumbnails code. For example, if you created a new image size with the name secondary-featured-thumbnail you would add this code in your template:


if (class_exists('MultiPostThumbnails')) : 

MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image', NULL,  'secondary-featured-thumbnail');



We hope that this article helped you add multiple featured images to your WordPress themes. What are some use cases that you can think of for this plugin? When can you see yourself adding multiple post thumbnails in WordPress? Let us know by leaving a comment below.

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi. Page maintained by Syed Balkhi.

WPBeginner's Video Icon
Our HD-Quality tutorial videos for WordPress Beginners will teach you how to use WordPress to create and manage your own website in about an hour. Get started now »


  1. yasir kham says:

    it really help full for me Thank’s

  2. Brian says:

    Can you add it to just one page in the admin area. Like if i wanted to just add it to the front-page.php file in the admin area so if you go to edit another page it is not on it in the admin area?

  3. birjit says:

    how to get secoundry featured image id

  4. Neil desucatan says:

    Hi i’m new with wordpress and i hope you can help me :) with this

    i need to use this to my sidebar.php but now showing the secondary image

  5. Anas Iqbal says:

    Hi, I am using this plugin with NewsPaper WordPress theme but everytime it display the latest secondary image added in all post.

    Like I display 6 posts in sidebar, and secondary image was added in just first 2 posts, but the same image will display in all 6 posts.

    Please tell me how can I use this with NewsPaper WordPress theme.

  6. Joseph says:

    this isn’t working for me, 2nd featured image is not showing in page editor.

  7. Barrett Hemmings says:

    Is there a way to use this method to assign a secondary featured image based on a category that is chosen? I am building a site for a reclaimed wood company that does all kinds of projects and some of the project photos have multiple categories within them. For instance, one project we did has items throughout the house that we did, and we included the category “Shelves” to a posting that the featured image doesn’t show any shelves. That project will be displayed within a page of shelves and have the featured image of a counter top. Is there any way to make it display one of the photos of the shelves when it is displayed in this category?

    • Ankita says:

      there is always an id for any post type so in your case if it is “shelves” then ‘post_type’ => ‘shelves’ will be in your code.

  8. tareq says:

    It’s really working on post. bt i wanna set it on custom post. How can i add multiple feature image in custom post?

  9. Patrick Buntsma says:

    It might be very easy, but I cannot seem to get it right…
    How do I get it to show up in all my post types? The ‘post_type’ => ‘post’ only makes it available in WP Posts. I need it in ‘page’ and ‘event’ as well.

    Please advice.

  10. Abdul wahab says:

    The 2nd feature image is not showing,how i can get the image ID?

  11. David says:

    How can i get the ID of the extra Thumbnail?

  12. Anas Naqvi says:

    for multiple feature images copy this code in your functions,php

    if (class_exists(‘MultiPostThumbnails’)) {

    for($i=2; $i ‘Secondary Image-‘.$i,

    ‘id’ => ‘secondary-image-‘.$i,

    ‘post_type’ => ‘page’




    In order to display your featured image paste this code in your loop of your single.php/page.php where you want to display the images.

    if (class_exists(‘MultiPostThumbnails’)) :

    for($i=2; $i<=5; $i++)


    MultiPostThumbnails::the_post_thumbnail(get_post_type(), 'secondary-image-'.$i);



  13. Rajith Gunawardena says:

    this is a very useful tutorial.. So the admins doesn`t need to go to widgets as all items could be added at once ( if the items are unique to that post ./ page ) .. Does anyone of you guys know how we could have a similar one for featured text and extra text areas within the post ?

  14. Rajith Gunawardena says:

    this is very useful and i manage to get it to work without any issue. do you know how we could have a similer things with FEATURED TEXT and MULTiPLE FEATURED TEXT ?

  15. amitmojumder says:

    What if somebody wants to show more than 2 featured images? say 10-12?

    • KyawNaing Tun says:

      I solved it like this :)

      // in function.php

      if (class_exists(‘MultiPostThumbnails’)) {

      new MultiPostThumbnails(array(

      ‘label’ => ‘Secondary Image’,

      ‘id’ => ‘secondary-image’,

      ‘post_type’ => ‘product’

      ) );

      new MultiPostThumbnails(array(

      ‘label’ => ‘Third Image’,

      ‘id’ => ‘third-image’,

      ‘post_type’ => ‘product’

      ) );


      // in template

      if (class_exists(‘MultiPostThumbnails’)) :

      MultiPostThumbnails::the_post_thumbnail(get_post_type(), ‘secondary-image’);


      if (class_exists(‘MultiPostThumbnails’)) :

      MultiPostThumbnails::the_post_thumbnail(get_post_type(), ‘third-image’);


  16. MatsDagerlind says:

    I solved it like this (based on code provided in this article, its comments and other sources):

    MultiPostThumbnails::the_post_thumbnail(get_post_type(), ‘secondary-image’, NULL, ‘medium’);
    $mptId = MultiPostThumbnails::get_post_thumbnail_id(‘post’, ‘secondary-image’, $post->ID);
    $p = get_post($mptId);
    echo “”;
    echo apply_filters(‘the_excerpt’,$p->post_excerpt);
    echo “”;

  17. MatsDagerlind says:

    I know you explained in another topic ( how to get and show the caption (excerpt) for a thumbnail, but I don’t quite get how to do this in the context above. If someone could show what to add to the code sample to show the caption beneath the thumbnail, I would be very grateful.

  18. Vinnie James says:

    Is it possible to just return the image url without the tag when calling it up within the template file? Something similar to:

    //Get the Thumbnail URL
    $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), array(320,240), false, ” );
    echo $src[0];

    EDIT: Yes, there is. Use this —
    $custom = MultiPostThumbnails::get_post_thumbnail_id(‘post’, ‘secondary-image’, $post->ID); $custom=wp_get_attachment_image_src($custom,’post-secondary-image-thumbnail’); echo $custom[0];

  19. Masood says:

    Thank you for this article its very help full for bigner like me

  20. gunadi says:

    hi, this perfect plugin.
    but, can i create slider with this plugin..?

    thank’s :)

  21. Mehdi says:

    Hi, Thank you for your work :)

    Using this plugin, can I add more than 1 additional Thumbnail image ??

    Thank you.

    • WPBeginner Support says:

      Yes you can.

      • Mehdi says:

        Awesome! But it looks that from the back-office I can only add One secondary image. How can I achieve that ?
        Thank you.

        • Mehdi says:

          Sorry, this is how we can do it :

          // To be Added in functions.php
          // Multi-Thumbnails code
          if (class_exists(‘MultiPostThumbnails’)) {
          for($i = 1; $i ‘Gallery Image’.$i,
          ‘id’ => ‘image-‘.$i,
          ‘post_type’ => ‘post’

          Thank you.

  22. Steve says:

    Great article!

    Just what I’ve been looking for.

    But how I could make it work with a custom post type?

  23. abid says:

    got it, just copy and past this function how many time you want feature images, and change id and label…:)

  24. abid says:

    how to add upto 5 or 6 features images…?

  25. abdul says:

    What is different between default image and featured image in wordpress./////////////??????????

    • WPBeginner Support says:

      The featured image is an image that you can attach to a post using the featured image box in the post edit area. If you want, you can set a default fallback image for your featured images. This default featured image will appear when there is no featured image set for a post.

  26. Gunaseelan says:

    I have created a plugin for displaying Page Title, Featured Image and the content.

    Instead of displaying featured image, I need to display the secondary image that is uploaded via plugin.

    How to accomplish this? I will share a small part of my plugin. Please go through it.

    function widget($args, $instance) {
    extract( $args );
    $title = apply_filters(‘widget_title’, $instance[‘title’]);
    $page_id = $instance[‘page_id’];
    $featured_image = get_the_post_thumbnail($page_id);
    $image = $instance[$featured_image];
    echo $featured_image;


    $content = strip_shortcodes($content);
    $content = apply_filters(‘the_content’, $content);
    echo $this->break_text($content, $page_id);



    • WPBeginner Support says:

      Please use support tab on plugin’s page at also check out the FAQs there.

  27. Eoghan says:

    I cannot get the resize part to work for me.

    I add image size in functions.php:
    add_image_size(‘small-featured-image-size’, 250, 150);

    I add my image:
    if (class_exists(‘MultiPostThumbnails’)) {
    new MultiPostThumbnails(
    ‘label’ => ‘Small Featured Image’,
    ‘id’ => ‘smaller-featured-image’,
    ‘post_type’ => ‘product’

    And then:
    if( class_exists(‘MultiPostThumbnails’) ) {
    MultiPostThumbnails::the_post_thumbnail(‘product’, ‘smaller-featured-image’, NULL, ‘small-featured-image-size’);

    The image keeps coming out on the page as its original size. Can anyone help me?

    • WPBeginner Support says:

      Eoghan first you need to create ‘smaller-featured-image’ image size. Check out how to create additional image sizes in WordPress and then how to regenerate thumbnails.

    • wgoodman says:

      I tried to get it to work by copying the code on this page and pasting it in my functions.php. It did not work until I realized that I was pasting smart apostrophes. Once I changed them it worked great. I think this is what happen to EOGHAN. Thank you for making this webpage. It really is helping my project.

  28. David says:

    Hey Thanks!!

    I Have a cuestion.
    can i display this on a slider on the single page?

  29. Joshua says:

    Hey, I’m trying to figure out how to turn this block of code into an array that can be used outside of the loop (in a foreach loop thats after the post loop).

    if (class_exists(‘MultiPostThumbnails’)) :

    MultiPostThumbnails::the_post_thumbnail(get_post_type(), ‘secondary-image’);


    How would you do this? Great tutorials by the way!

  30. Rajeev says:

    Please give me idea to add two featured images from front-end using code.

  31. Aura Ide says:

    Thank you for this article as I was looking for a long time, it turns out I found here. We will practice immediately. The tutorial is very clear, good luck!

  32. Travis Pflanz says:

    To improve on this idea, you could just use a custom meta box/fields plugin or create a custom repeatable field… To allow different number of “post thumbnails”

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.