Support » Plugin: Multiple Featured Images » Image isn’t displaying in template

  • I tried to follow the instructions in order to display the second featured image but the page isn’t displaying the second image. First, I added this following code to functions.php after installing the plugin.

    add_filter( 'kdmfi_featured_images', function( $featured_images ) {
    $args = array(
    'id' => 'featured-image-2',
    'desc' => 'Your description here.',
    'label_name' => 'Featured Image 2',
    'label_set' => 'Set featured image 2',
    'label_remove' => 'Remove featured image 2',
    'label_use' => 'Set featured image 2',
    'post_type' => array( 'galeria' ),
    );
    
    $featured_images[] = $args;
    
    return $featured_images;
    });

    Then, after adding a photo to the second featured image in the post, I tried to add the following code to the single.php.

    <div class="single_image">
    <?php
    	if(has_post_thumbnail()) {                    
    	    $image_src = wp_get_attachment_image_src( get_post_thumbnail_id(),'full' );
    	     echo '<img src="' . $image_src[0]  . '" width="100%"  />';
    	} 
    ?>
    
    <?php 
    if( kdmfi_has_featured_image() ) {
    	$secondimage_src =   kdmfi_get_featured_image_src( 'featured-image-2', 'full' );
    	     echo '<img src="' . $secondimage_src[0]  . '" width="100%"  />';
    }
    ?>
    </div>

    As you can see, the first part display the first featured image. However the last part wouldn’t display the second featured image. Please help!

  • The topic ‘Image isn’t displaying in template’ is closed to new replies.