Title: [Plugin: Multiple Post Thumbnails] Image not displaying
Last modified: August 19, 2016

---

# [Plugin: Multiple Post Thumbnails] Image not displaying

 *  Resolved [zeckdude](https://wordpress.org/support/users/zeckdude/)
 * (@zeckdude)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/)
 * I can get the Secondary Image Upload box to show up in the admin area, but I 
   can’t manage to get the image to display on the page.
 * This is the code I am using to try and make it display (From: [http://wordpress.org/extend/plugins/multiple-post-thumbnails/installation/](http://wordpress.org/extend/plugins/multiple-post-thumbnails/installation/)):
 *     ```
       <?php if (class_exists('MultiPostThumbnails')
           && MultiPostThumbnails::has_post_thumbnail('post', 'secondary-image')) :
               MultiPostThumbnails::the_post_thumbnail('post', 'secondary-image'); endif; ?>
       ```
   
 * I tried adding a random echo inside the if statement to see if it gets hit, but
   it doesn’t echo out, so i’m guessing somehow the condition is not being met?
 * What am I missing?

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/page/2/?output_format=md)

 *  [Drew Gourley](https://wordpress.org/support/users/drewgourley/)
 * (@drewgourley)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/#post-1614414)
 * make sure that the post type matches up with the post type you declared when 
   you register the post thumbnails.
 * The author shows
 *     ```
       $thumb = new MultiPostThumbnails(array(
           'label' => 'Secondary Image',
           'id' => 'secondary-image',
           'post_type' => 'page'
           )
       );
       ```
   
 * but then incorrectly tells you to put this in the template:
 *     ```
       <?php if (class_exists('MultiPostThumbnails')
           && MultiPostThumbnails::has_post_thumbnail('post', 'secondary-image')) :
               MultiPostThumbnails::the_post_thumbnail('post', 'secondary-image'); endif; ?>
       ```
   
 * if you registered it as post-type => page, then you’d have to use:
 *     ```
       <?php if (class_exists('MultiPostThumbnails')
           && MultiPostThumbnails::has_post_thumbnail('page', 'secondary-image')) :
               MultiPostThumbnails::the_post_thumbnail('page', 'secondary-image'); endif; ?>
       ```
   
 * This got it all working for me.
 * Don’t forget, this is really versatile! You could literally register ten or more
   post-thumbnails by giving them unique identifiers when registering them. Exciting
   stuff!
 *  Thread Starter [zeckdude](https://wordpress.org/support/users/zeckdude/)
 * (@zeckdude)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/#post-1614435)
 * Drew, thanks for the response. I appreciate the help!
 * I changed the code as you suggested and it didn’t change anything unfortunately.
 * Here is everything I have done with this plugin:
 * I am using the twentyten theme as a parent them for a new theme I’m making.
 * I activated the plugin.
 * **I put this in my functions.php file:**
 *     ```
       $thumb = new MultiPostThumbnails(array(
           'label' => 'Secondary Image',
           'id' => 'secondary-image',
           'post_type' => 'page'
          )
       );
       ```
   
 * **I put this in my page.php file:**
 *     ```
       if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('page', 'secondary-image')) :
                           echo 'This condition is met';
                           MultiPostThumbnails::the_post_thumbnail('page', 'secondary-image'); endif;
       ```
   
 * It said ‘post’ before, and I changed it to ‘page’ now, but that does not fix 
   the problem.
 * I uploaded an image, I can see the image uploads, it adds a new custom field 
   with the name ‘post_secondary-image_thumbnail_id’ and the correct id number(i
   checked the database and it inserts the image location correctly).
 *  [Drew Gourley](https://wordpress.org/support/users/drewgourley/)
 * (@drewgourley)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/#post-1614520)
 * Sorry to hear that this didn’t work, but there is one difference between yours
   and mine. I changed the way the condition was formatted. This is a long shot,
   because everything you’ve done SHOULD make it work, but it hasn’t… Here is the
   exact code from my page.php:
 *     ```
       <?php if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('page', 'secondary-image')) { ?>
       <div id="secondaryImage">
       	<?php MultiPostThumbnails::the_post_thumbnail('page', 'secondary-image'); ?>
       </div>
       <?php } ?>
       ```
   
 * And the div isn’t necessary, its for CSS so:
 *     ```
       <?php if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('page', 'secondary-image')) {
         MultiPostThumbnails::the_post_thumbnail('page', 'secondary-image');
       } ?>
       ```
   
 *  [Abdussamad Abdurrazzaq](https://wordpress.org/support/users/abdussamad/)
 * (@abdussamad)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/#post-1614553)
 * Zeckdude I had the same problem as you and I figured out how to fix it. Just 
   omit the “$thumb =” part. You don’t have to assign the object to any variable.
   Put the following in functions.php:
 *     ```
       new MultiPostThumbnails(array(
           'label' => 'Secondary Image',
           'id' => 'secondary-image',
           'post_type' => 'page'
          )
       );
       ```
   
 *  [Drew Gourley](https://wordpress.org/support/users/drewgourley/)
 * (@drewgourley)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/#post-1614554)
 * Ha, nice.
 * Really odd is that it works for me both ways…
 *  Thread Starter [zeckdude](https://wordpress.org/support/users/zeckdude/)
 * (@zeckdude)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/#post-1614559)
 * I had not placed my code inside the loop for the content for that particular 
   page. Rookie Mistake!
 *  [takeok](https://wordpress.org/support/users/takeok/)
 * (@takeok)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/#post-1614614)
 * redacted
 *  [casper83](https://wordpress.org/support/users/casper83/)
 * (@casper83)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/#post-1614618)
 * worked with me when i entered the post id
 *     ```
       if (class_exists('MultiPostThumbnails')
           && MultiPostThumbnails::has_post_thumbnail('page', 'secondary-image',$post->ID)) :
           MultiPostThumbnails::the_post_thumbnail('page', 'secondary-image', $post->ID, 'fifth-image');
           endif;
       ```
   
 *  [Vitaliy Sopko](https://wordpress.org/support/users/vsopko/)
 * (@vsopko)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/#post-1614629)
 * > worked with me when i entered the post id
 * Yeah, it works for me too! Thank you, casper83! Nice solution.
 *  [www.agentstaobao.com](https://wordpress.org/support/users/wwwagentstaobaocom/)
 * (@wwwagentstaobaocom)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/#post-1614630)
 * Yeah, it works for me too! Thank you, casper83! Nice solution.
 *  [paul-g](https://wordpress.org/support/users/paul-g/)
 * (@paul-g)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/#post-1614631)
 * Yeah, it works for me too! Thank you, casper83! Nice solution.
 *  [themagiclaundry](https://wordpress.org/support/users/themagiclaundry/)
 * (@themagiclaundry)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/#post-1614632)
 * hello,
 * where in functions.php do i put this code?
 *     ```
       $thumb = new MultiPostThumbnails(array(
           'label' => 'Secondary Image',
           'id' => 'secondary-image',
           'post_type' => 'page'
          )
       );
       ```
   
 * i tried putting it on the top of the page and at the bottom and i get errors.
 *  [flick](https://wordpress.org/support/users/mosey/)
 * (@mosey)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/#post-1614633)
 * [@themagiclaundry](https://wordpress.org/support/users/themagiclaundry/): This
   has to go between `<?php` and `?>`
 *  [themagiclaundry](https://wordpress.org/support/users/themagiclaundry/)
 * (@themagiclaundry)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/#post-1614634)
 * so i was able to get the code inserted without errors now. when i goto posts,
   i see the secondary featured image. and i click “set as featured” or “set as 
   secondary” but no matter what, no picture will appear on my page.
 * the only way i can get an image to appear is if i use the “Featured” custom field.
   but that only allows me 1 picture per posts
 *  [flick](https://wordpress.org/support/users/mosey/)
 * (@mosey)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/#post-1614635)
 * Have you also used the template code for e.g. single.php?
 * The code in functions.php helps WordPress recognise that it is a second featured
   image. The template code asks WordPress to display it.

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/page/2/?output_format=md)

The topic ‘[Plugin: Multiple Post Thumbnails] Image not displaying’ is closed to
new replies.

 * 19 replies
 * 10 participants
 * Last reply from: [flick](https://wordpress.org/support/users/mosey/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/plugin-multiple-post-thumbnails-image-not-displaying/page/2/#post-1614639)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
