ok I figured this out and wanted to share. You have to add the Custom Post Type in as well, see 'post-type' => 'landing pages
if (class_exists('MultiPostThumbnails')) { // imports to post_type pages
new MultiPostThumbnails(array('label' => '2nd Feature Image', 'id' => 'feature-image-2', 'post_type' => 'page', 'post_type' => 'landing_pages')); /* 'post_type' => 'landing_pages' adds support for landing pages CPT */
new MultiPostThumbnails(array('label' => '3rd Feature Image', 'id' => 'feature-image-3', 'post_type' => 'page', 'post_type' => 'landing_pages'));
new MultiPostThumbnails(array('label' => '4th Feature Image', 'id' => 'feature-image-4', 'post_type' => 'page', 'post_type' => 'landing_pages'));
new MultiPostThumbnails(array('label' => '5th Feature Image', 'id' => 'feature-image-5', 'post_type' => 'page', 'post_type' => 'landing_pages'));
};
Forgot to mention to display the images I placed the below code in the template for the landing pages CPT:
if (class_exists('MultiPostThumbnails')
&& MultiPostThumbnails::has_post_thumbnail('landing_pages', 'feature-image-2')) :
MultiPostThumbnails::the_post_thumbnail('landing_pages', 'feature-image-2', NULL /*, 'add class name here' */ ); endif;
if (class_exists('MultiPostThumbnails')
&& MultiPostThumbnails::has_post_thumbnail('landing_pages', 'feature-image-3')) :
MultiPostThumbnails::the_post_thumbnail('landing_pages', 'feature-image-3', NULL /*, 'add class name here' */ ); endif;
*** Does anyone know if there is a way to write an array or condense the code above so you dont have to list the post type twice:
'post_type' => 'page', 'post_type' => 'landing_pages'
I hope this helps someone out there, I wanted to make sure my last question was not hidden in my previous response:
*** Does anyone know if there is a way to write an array or condense the code below so you dont have to list the post type twice:
new MultiPostThumbnails(array('label' => '2nd Feature Image', 'id' => 'feature-image-2', 'post_type' => 'page', 'post_type' => 'landing_pages'));
Thanks.
My apologies, the code above after further testing was not working properly. Below is how I added support for pages, posts and CPT’s and have fully tested and it is working correctly.
add_theme_support( 'post-thumbnails' );
require_once('lib/multiple-post-thumbnails/multi-post-thumbnails.php'); /* Must be located directly under lib folder */
// Define additional "post thumbnails". Relies on MultiPostThumbnails to work
if (class_exists('MultiPostThumbnails')) {
$types = array('page', 'landing_pages' ); /* 'landing_pages' adds support for landing pages CPT, 'post' adds support for blog single pages */
foreach($types as $type) {
new MultiPostThumbnails(array('label' => '2nd Feature Image', 'id' => 'feature-image-2', 'post_type' => $type));
new MultiPostThumbnails(array('label' => '3rd Feature Image', 'id' => 'feature-image-3', 'post_type' => $type));
new MultiPostThumbnails(array('label' => '4th Feature Image', 'id' => 'feature-image-4', 'post_type' => $type));
new MultiPostThumbnails(array('label' => '5th Feature Image', 'id' => 'feature-image-5', 'post_type' => $type));
}
};
Then in your page templates place this code where you wish the image to appear:
if (class_exists('MultiPostThumbnails')
&& MultiPostThumbnails::has_post_thumbnail('landing_pages', 'feature-image-2')) :
MultiPostThumbnails::the_post_thumbnail('landing_pages', 'feature-image-2', NULL /*, 'add class name here' */ ); endif;
You can change where it says
'landing_pages'
to page or post if you are displaying on a page or a single page (blog post). The landing_pages is a custom post type I created.
Hope this helps and again if anyone has cleaner code please share.
A lot of Thanks!! Works great on my CP.