Support » Plugin: Dynamic Featured Image » Get second featured image

  • Resolved imaginocracy

    (@imaginocracy)


    Hi Ankit, thank you for the great plugin. I am sure I am close on this, but I cannot get the second image ONLY to display. I have two featured images on my post; I want to display the second featured image using this code.

    I am using this within a loop.

    if (function_exists('dfi_get_featured_images') ) {
    			$featuredImages = dfi_get_featured_images(1); //get second featured image
    			if( !is_null($featuredImages) ) { //if value is not null
    				echo '<div class="featured-image featured-image-desktop hidden-xs">'; //create featured image wrapper
    				foreach($featuredImages as $images) {
    					echo '<img src="' . $images['desktop'] . "' />";
    				}
    				echo '</div>'//close image wrapper
    
    			}
    		}

    “desktop” is a custom image size I created in my functions.php file.

    https://wordpress.org/plugins/dynamic-featured-image/

Viewing 4 replies - 1 through 4 (of 4 total)
  • imaginocracy

    (@imaginocracy)

    Update:

    <?php
    	/** single product featured image (second featured image)
    	 *
    	 */
    
    		if (function_exists('dfi_get_featured_images') ) {
    
    			$featuredImages = dfi_get_featured_images( $returnedArray[1] );
    
    			if( !is_null($featuredImages) ) {
    
    				echo '<div class="featured-image featured-image-desktop hidden-xs">'; // featured image wrapper
    
    				foreach($featuredImages as $images) {
    
    					echo '<img src="' . $images['full'] . '" />';
    
    				}
    
    				echo '</div>';
    
    			}
    		}
    ?>

    This works. Thanks for the great plugin Ankit!

    Plugin Author Ankit

    (@ankitpokhrel)

    Hello imaginocracy. Thank you for using the plugin. Glad to know that you solved your issue. Additionally this post shows how to get second featured image – http://ankitpokhrel.com.np/blog/fetching-information-from-the-returned-data/.

    Thanks,
    Ankit

    Barry Crump

    (@barry-crump)

    Thank you so much imaginocracy

    You code worked perfectly. I’m using this plugin to display a different custom banner for each post and couldn’t find any reference on this site to actually displaying the image. It seems to only cover retrieving the data.

    Ankit Pokhrel, you may want to display this snippet of code prominently on your plugin site, I feel like this would be one of the most common usages of your plugin. The ability to insert the secondary featured image anywhere in your theme.

    Awesome, thanks.

    imaginocracy

    (@imaginocracy)

    Barry, glad I could help, that was a tough nut. Ankit the missing link in your posts is how to use $returnedArray[X]. I had to piece together and troubleshoot my code via probably 4 or 5 different posts to figure it out.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get second featured image’ is closed to new replies.