Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I found a plugin called Multiple Post Thumbnails and followed the directions in getting it set up. Everything shows up correctly in the admin dashboard (i.e. shows two sections to upload two separate thumbnails) but after I set the two thumbnails for each post and view the page which displays those posts, only the first post I set the thumbnails for show up.

This is the code I used in my theme's functions.php:

$thumb = new MultiPostThumbnails(
    array(
    'label' => 'Larger Image',
    'id' => 'image2',
    'post_type' => 'projects'
    )
);

And here is my Projects page which is the page where the posts are displayed:

<section id="content">

        <section id="projects-list">
            <?php
                $c=0;
                $i=1;

                $temp = $wp_query;
                $wp_query = null;
                $wp_query = new WP_Query();
                $wp_query->query('post_type=projects' . '&paged=' . $paged . '&posts_per_page=6');

                while ( $wp_query->have_posts() ) : $wp_query->the_post(); $c++;
            ?>

            <article class="post<?php if($i%3 == 0) { echo ' right'; }; $i++; ?>" id="post-<?php the_ID(); ?>">
                <section class="entry">
                    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
                        <?php
                            if (class_exists('MultiPostThumbnails')
                            && MultiPostThumbnails::has_post_thumbnail('projects', 'secondary-image')) :
                            MultiPostThumbnails::the_post_thumbnail('projects', 'secondary-image');
                            endif;
                        ?>
                    </a>
                </section>
                <section class="description">
                    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
                    <time class="post-date" datetime="<?php the_time('c'); ?>"><?php the_time('F j, Y'); ?></time>
                </section>
            </article>

            <?php
                endwhile; 
                wp_pagenavi();
                $wp_query = null;
                $wp_query = $temp;
                wp_reset_query();
            ?>

            <?php if( $c < 6 ) : for ($dummy= $c; $dummy < 6; $dummy++) : ?>

                <article class="post<?php if($i%3 == 0) { echo ' right'; }; $i++; ?>" id="post-<?php the_ID(); ?>">
                    <img src="<?php bloginfo('template_url'); ?>/images/dummy-post.gif" alt="Post coming soon!" />
                </article>

                <?php endfor;?>

            <?php endif;?>
        </section>

        <section id="map">
            <img src="<?php bloginfo('template_url') ?>/images/interactive-map.jpg" alt="Interactive Map" />
        </section>

        <section id="youtube-subscribe">
            <iframe id="fr" src="http://www.youtube.com/subscribe_widget?p=mysteryguitarman"></iframe>
        </section>

</section>

Here is a screenshot of what the page looks like. Note only "Project 6" has the thumbnail showing (Project 6 was the first post I uploaded a second thumbnail to) when I uploaded second thumbnails for each of those posts.

Projects Page

Does anybody have experience with this plugin? Also, would anyone suggest an alternative no-plugin way to achieve the same thing? Basically, I just want to be able to upload two separate thumbnails for each post in the Projects post type so one shows on the home page and another (larger) one shows on the Projects page. An ideal setup would be to have just one large image I upload which gets shown on the Projects page and it would automatically get cropped into a smaller thumbnail which I can then use for the home page. Anyhow, any advice/help would be much appreciated. Thank you for reading this long post!

share|improve this question
    
i think you must set the id on the arguments (See $thumb Variable). The id must be have the Post-id, right? i have installed the plugin. Hmm.. The second image will not be displayed.. –  user12910 Feb 8 '12 at 16:44

3 Answers 3

up vote 5 down vote accepted

Dude, you're doing this the hard way. You can do what you want totally with a single 'featured post thumbnail'. Read the documentation about thumbnail sizes in themes. You can inject custom thumbnail sizes in your themes funcitons.php and then give them as a parameter to the (get_)the_post_thumbnail() function. Please just read the documentation at the Codex - start with the function reference page for the_post_thumbnail(), maybe - and you'll see. Wordpress does automatically resize and crop the image for you, if only you tell it to do so.

share|improve this answer
    
You're the man. Thanks! –  J82 Feb 20 '11 at 1:07
2  
It was about time someone realizes that. scnr –  wyrfel Feb 20 '11 at 1:16

With Multiple Post Thumbnails you can set 2 or more different images, WordPress's built-in the_post_thumbnail() cannot do that

share|improve this answer

I know its an old question but there is a new plugin called Dynamic Featured Image. It will allow you to add multiple featured image using a graphical interface. It will save lot of your development time.

The Plugin dynamically adds multiple featured image (post thumbnail) functionality to posts, pages and custom post types.

enter image description here

share|improve this answer
    
Do not post duplicate answers. If you see a question that could be solved by exact the same answer, mark it as duplicate. –  toscho Nov 15 '13 at 10:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.