Thursday, 7 July 2016

How to display multiple featured images

Dynamic featured image

Use dynamic featured image plugin for multiple featured images.
Copy the below code in your template or content-page.php file. You will have multiple images.

<div class="post-thumbnail">
  <?php  
           if( class_exists('Dynamic_Featured_Image') )
           {
             global $dynamic_featured_image;
             $featured_images = $dynamic_featured_image->get_featured_images();
            }   
               //echo "<pre>";print_r($featured_images);
            $attachment_cnt = count($featured_images);
            for($i=0;$i<$attachment_cnt;$i++)
            { ?><img src="<?php echo $featured_images[$i]['full'];?>" sizes="(max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 60vw, (max-width: 1362px) 62vw, 840px" class="attachment-post-thumbnail size-post-thumbnail wp-post-image" style="margin-bottom:10px;"><?php } ?>
  </div>

No comments:

Post a Comment