Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Ankit Pokhrel

    (@ankitpokhrel)

    You can use get_nth_featured_image method to get and display 2nd featured image anywhere you want.

    Regards,
    Ankit

    Thread Starter jennetdot1

    (@jennetdot1)

    please can you give me a little tuto how to do it? i saw this on a post but now what to add to functions.php

    <?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>';
    
    			}
    		}
    ?>
    Plugin Author Ankit Pokhrel

    (@ankitpokhrel)

    You can do something like this. Please read comments too.

    <?php
    if( class_exists('Dynamic_Featured_Image') ) {
         global $dynamic_featured_image;
         $featured_images = $dynamic_featured_image->get_featured_images( get_the_ID() );
    
        //If you want to display all featured images you can loop through the image to display them as required
        foreach( $featured_images as $image ) {
            echo "<a href='{$image['full']}'>";
                echo "<img src='{$image['thumb']}' alt='Dynamic Featured Image' />";
            echo "</a>";
        }
    
        //if you only want to show 2nd featured image you can do
        if (isset($featured_images[0])) {
        	$image = $featured_images[0];
        	echo "<a href='{$image['full']}'>";
                echo "<img src='{$image['thumb']}' alt='Dynamic Featured Image' />";
            echo "</a>";
        }
     }

    Regards,
    Ankit

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to show only 2nd featured img on home/blog’ is closed to new replies.