Multiple Post Thumbnails Not Returning URL for Background Image

I’ve been using the Multiple Post Thumbnail plugin with my custom post types to use a secondary, smaller image on my archive pages, while I have a larger hero image in the header of the single post (these are two different images, not a smaller and larger version of the same image).

Previously, the code worked well, but suddenly it stopped returning the post thumb url.

The code in my functions.php file:

if (class_exists(‘MultiPostThumbnails’)) {
new MultiPostThumbnails(
array(
‘label’ => ‘Secondary Image’,
‘id’ => ‘secondary-image’,
‘post_type’ => ‘episodes’
)
);
}
if (class_exists(‘MultiPostThumbnails’)) {
new MultiPostThumbnails(
array(
‘label’ => ‘Secondary Image’,
‘id’ => ‘secondary-image’,
‘post_type’ => ‘resources’
)
);
}

The code in the loops on my custom post types’ archive pages:

<? $custhumburl = MultiPostThumbnails::get_post_thumbnail_url(‘episodes’, ‘secondary-image’, NULL, ‘secondary-image’); ?>

<div id=”post-<?php the_ID(); ?>” <?php post_class(‘grid-box inline-item thumb’) ?> itemscope itemtype=”https://schema.org/thumbnail”>

<a href=”<?php the_permalink(); ?>” itemprop=”significantLink”>

<span class=”display-block wp-post-image” style=”background-image:url(<?php echo $custhumburl ?>);”></span>

<span class=”bg-gray-solid border-radius-bottom display-block lato all-padding”>

<h3 class=”center-text gray-text lato letter-spacing-heading sub-heading-font text-padding uppercase” itemprop=”title”><?php the_subtitle(); ?></h3>

<h2 class=”black-text capitalize center-text font-light heading-font roboto” itemprop=”title”><?php the_title(); ?></h2>

</span><!– End post meta –>
</a><!– End post anchor tag –>
</div><!– End grid-box – post thumbnail –>

When I open Dev Tools, the image url is blank:

<span class=”display-block wp-post-image” style=”background-image:url();”></span>

Read more here:: Multiple Post Thumbnails Not Returning URL for Background Image

Leave a Reply

Your email address will not be published. Required fields are marked *