Currently I'm trying to create a large header (jumbotron) on my website. The large header is loaded as inline css with the following code:

<div class="fill" style="background-image:url('<?php echo img url ?>')"></div>

I'm using the Multi-post-thumbnails plugin to create metaboxes to upload extra images. The image I'm trying to load is 'header-image'. The plugin normaly creates the complete etc which I don't need.

Does anyone know how I can get the URL of the image?

2 Answers 2


found the solution:

<div class="fill" style="background-image:url('<?php $custom = MultiPostThumbnails::get_post_thumbnail_id(get_post_type(), 'header-image', $post->ID); $custom=wp_get_attachment_image_src($custom,'header image'); echo $custom[0]; ?>');"></div>

The easiest way to get the URL for the thumbnail would be:

<?php echo MultiPostThumbnails::get_post_thumbnail_url(get_post_type(), 'header-image', $post->ID); ?>
  • Oh did not notice that this question was like super old =) Commented Sep 8, 2020 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.