You’re trying to get the thumbnail URL to use inside an inline style. You’ll need [the_post_thumbnail_url()][1]
to do so. the_post_thumbnail()
returns the actual image, not the URL of the image (which you need to display it as a background image.
This particular plugin provides the get_post_thumbnail_url()
function to do so.
You would use it like this (including the background-image property):
style="background-image: url('<?php MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'secondary-image'); ?>');"
Also, note that if you’re calling the the_post_thumbnail()
function outside the loop you will need to provide a $post_id
.
<?php
$attr = array(
'id' => get_the_ID(),
);
MultiPostThumbnails::the_post_thumbnail( get_post_type(), 'secondary-image', $attr );
?>
See the_post_thumbnail() in the WordPress codex, and the multi post thumbnails plugin Wiki and source code to see their implementation.