views:

51

answers:

1

I am using wordpress and am using featured images(they used to be called post thumbnails). I wanted to use multiple featured images, so I chose to use the Multiple Post Thumbnails Plugin.

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/):

<?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?

+1  A: 

First of all, I guess it is necessary to enable thumbnails, too:

// This theme uses post thumbnails
add_theme_support( 'post-thumbnails' );

Then you have to add something like

if (class_exists('MultiPostThumbnails')) {
    $types = array('post', 'page', 'my_post_type');
    foreach($types as $type) {
        $thumb = new MultiPostThumbnails(array(
            'label' => 'Secondary Image',
            'id' => 'secondary-image',
            'post_type' => $type
            )
        );
    }
}

in your themes functions.php file within the theme_setup() {...} function.

HTH, mtness.

mtness
What is the theme_setup function?
zeckdude
I figured out my mistake. I didn't place it within the loop for the post. Rookie mistake!
zeckdude