0

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>
  • Can you please let me know which plugin or code is used for "the_subtitle" ??? – Tanmay Patel Apr 13 at 4:01
  • @TanmayPatel "WP Subtitle" by Ben Huson and Husani Oakley. – Codette Apr 13 at 4:19
  • Can you please give me screenshot of any one post of episodes/resources from admin side. so I can help you to fix this issue. – Tanmay Patel Apr 13 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.