Multiple Post Thumbnails

Often, the WordPress Plugin Multiple Post Thumbnails is used within the page.php and single.php templates, and few conflicts arise. If you’re calling your thumbnails within header.php, footer.php or functions.php, the following code will help sort out issues with images not displaying via the simpler methods.

if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('post', 'secondary-image',$post->ID)) : MultiPostThumbnails::the_post_thumbnail('post', 'secondary-image', $post->ID, 'secondary-image'); 
if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('page', 'secondary-image',$post->ID)) : MultiPostThumbnails::the_post_thumbnail('page', 'secondary-image', $post->ID, 'secondary-image'); 
if (class_exists('MultiPostThumbnails') && MultiPostThumbnails::has_post_thumbnail('custom_post_type', 'secondary-image',$post->ID)) : MultiPostThumbnails::the_post_thumbnail('custom_post_type', 'secondary-image', $post->ID, 'secondary-image'); 

Sourced here in the WordPress support forums.

Leave a Reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.