WordPress display multiple thumbnails in recent posts plugin

I would really appreciate any help on that issue.
I’d like to display a second thumbail in recent posts section at the bottom of each single post template.

I’m using multipost thumbnails plug-in for wordpress.
https://github.com/voceconnect/multi-post-thumbnails

Read More

and I’m using this code in my bottom widget area, which is working fine, but instead of a secondary image of each recent post, it shows a secondary image of a current post from above.

<?php $recent_posts = wp_get_recent_posts(55);
foreach( $recent_posts as $recent ){
if($recent['post_status']=="publish"){
if ( has_post_thumbnail($recent["ID"])) { 
echo  '<div id="main-grid">'
. '<a href="' . get_permalink($recent["ID"]) 
. '" title="Look '.esc_attr($recent["post_title"]).'" >'
.   get_the_post_thumbnail($recent["ID"], 'large-thumb') 
.   MultiPostThumbnails::get_the_post_thumbnail('post','secondary-image')
. '<header class="entry-header"><h1>' 
.  $recent ["post_title"]
. '</h1></header>'
. '</a></div> ';
} 
}
}
?>

Related posts

Leave a Reply

1 comment

  1. You did not hand over the $recent["ID"] to the MultiPostThumbnails function

    <?php 
    $recent_posts = wp_get_recent_posts(55);
    foreach( $recent_posts as $recent ){
        if($recent['post_status']=="publish"){
            if ( has_post_thumbnail($recent["ID"])) {
                echo  '<div id="main-grid">'
                . '<a href="' . get_permalink($recent["ID"])
                . '" title="Look '.esc_attr($recent["post_title"]).'" >'
                .   get_the_post_thumbnail($recent["ID"], 'large-thumb')
                .MultiPostThumbnails::get_the_post_thumbnail(
                    'post',
                    'secondary-image',
                    $recent["ID"],
                    'large-thumb'
                )
                . '<header class="entry-header"><h1>'
                .  $recent ["post_title"]
                . '</h1></header>'
                . '</a></div> ';
            }
        }
    }
    ?>
    

    Here you can find the function signature of get_the_post_thumbnail().