I am trying to add a class to the post thumbnails but when I add the class it doesn't display the thumbnail. This also happens with the image size and I'm wondering if I'm doing something wrong. I have 2 post thumbnails ID "banner-image" and ID "right-small-image"
In the function.php file I have:
add_theme_support( 'post-thumbnails' );
add_image_size('slider-background', '975', '345', true);
add_image_size('right-small', '250', '200');
add_image_size('wide-banner', '600', '200');
if (class_exists('MultiPostThumbnails')) {
new MultiPostThumbnails(
array(
'label' => 'Top Banner Image',
'id' => 'banner-image',
'post_type' => 'page'
)
);
new MultiPostThumbnails(
array(
'label' => 'Top Right Small Image',
'id' => 'right-small-image',
'post_type' => 'page'
)
);
}
In the page itself I have the code to display the two post thumbnail types:
<?php
// If the page has a banner image display it here
if (class_exists('MultiPostThumbnails')) :
$attr = array("class" => "banner-feature-image");
MultiPostThumbnails::the_post_thumbnail(
get_post_type(),
"banner-image",
"wide-banner",
$attr
);
endif;
?>
<?php
// If the page has a small right image on the top, beneath the heading, display it here
if (class_exists('MultiPostThumbnails')) :
$attr = array("class" => "right-small-feature-image");
MultiPostThumbnails::the_post_thumbnail(
get_post_type(),
"right-small-image",
"right-small",
$attr
);
endif;
?>
Is there some sort of issue with my syntax? Or is there some sort of bug?
It works just fine when I exclude the image size and the $attr at the end. When I include either of these the image stops showing up in the page and html output.
Thank you for making this incredibly useful plugin and for your time and consideration.
You're missing the post_id as the 3rd parameter in the call to MultiPostThumbnails::the_post_thumbnail(). See the function declaration or the docs for more info.
I am trying to add a class to the post thumbnails but when I add the class it doesn't display the thumbnail. This also happens with the image size and I'm wondering if I'm doing something wrong. I have 2 post thumbnails ID "banner-image" and ID "right-small-image"
In the function.php file I have:
In the page itself I have the code to display the two post thumbnail types:
Is there some sort of issue with my syntax? Or is there some sort of bug?
It works just fine when I exclude the image size and the $attr at the end. When I include either of these the image stops showing up in the page and html output.
Thank you for making this incredibly useful plugin and for your time and consideration.