WordPress.org

Forums

Dynamic Featured Image
[resolved] Multiple Featured Images Not Showing in Homepage Slider (8 posts)

  1. laurenfae
    Member
    Posted 1 year ago #

    Hi there,

    I recently installed the Dynamic Featured Image plugin for my wordpress site so I could use multiple images from each post in the slider on my homepage. I was able to add additional featured images to my posts, however they are not showing up in the slideshow. Any help would be most appreciated, as it says on the plugin page that this is possible.

    My website: http://www.laurenmclaughlin.com

    Thanks!

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

  2. Ankit Pokhrel
    Member
    Plugin Author

    Posted 1 year ago #

    Hello laurenfae,

    Yes, it is possible! You need to fetch the featured image and display it in your page manually.

    Example Code:

    if( class_exists('Dynamic_Featured_Image') ) {
         global $dynamic_featured_image;
         $featuredImages = $dynamic_featured_image->get_featured_images( $postId );
    
       //Loop through the image to display your image
    
       if( !is_null($featuredImages) ){
    
            $links = array();
    
            foreach($featuredImages as $images){
                $thumb = $images['thumb'];
                $fullImage = $images['full'];
    
                $links[] = "<a href='{$fullImage}' class='dfiImageLink'><img src='{$thumb}' alt='' height='{$height}' width='{$width}' /></a>";
            }
    
            echo "<div class='dfiImages'>";
            foreach($links as $link){
              echo $link;
            }
            echo "<div style='clear:both'></div>";
            echo "</div>";
         }
    
    }

    Thanks,
    Ankit

  3. laurenfae
    Member
    Posted 1 year ago #

    Hello Ankit,

    Thanks for the response and the code! So do I paste this into the theme's code? Or will this go into the code for each post? I'm trying to use multiple featured images for each post I create. I'm sure you get this often… I'm not terribly proficient with HTML and CSS. Thank you!

  4. laurenfae
    Member
    Posted 1 year ago #

    Hey again,

    So I figured out that I have to paste the code into the functions.php file… Am I correct? Although when I pasted it, the code just showed up at the top of my website's homepage so I'm still doing something wrong. I may need the idiot's guide to HTML… haha. Thanks again for your help.

  5. Ankit Pokhrel
    Member
    Plugin Author

    Posted 1 year ago #

    Hello Leurenfae,

    functions.php file is not a good place to add that script. Place it at the place where you want the images to be displayed. For example, if you want to display it in a page you should add it somewhere in page.php but it depends on how the the theme you are using is created.

    Thanks,
    Ankit

  6. kbengmy
    Member
    Posted 1 year ago #

    Ankit,

    Thanks for the nice plugin.

    I tried your example code above. I notice that it doesn't retrieve the 1st feature image (wordpress default).

    It successfully retrieve 2nd feature image onwards.

    Any idea?

    Thanks.

  7. Ankit Pokhrel
    Member
    Plugin Author

    Posted 1 year ago #

    Hello @kbengmy,

    Glad to know that you like the plugin. The function for that will be included in the next release.

    Regards,
    Ankit

  8. kbengmy
    Member
    Posted 1 year ago #

    Ankit,

    Thanks for the replied.

    I thought I did something wrong.

    I use it for portfolio display images.

    Thanks again for the nice plugin.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Dynamic Featured Image
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic