0

I want to show only 2nd featured image on home/blog.

Plugin is this: http://wordpress.org/support/plugin/dynamic-featured-image

Developer told me that I can do something like this:

<?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>";
    }

 }

Can someone help me to do this. Do i need to add something in functions.php or how? thanks in advance.

Check also this link, my discussion with developer: https://wordpress.org/support/topic/how-to-show-only-2nd-featured-img-on-homeblog?replies=4

0

Edit: This need to be placed into your template.

if( class_exists('Dynamic_Featured_Image') ) {
//if you only want to show 2nd featured image you can do
    if (isset($featured_images[1])) {
        $image = $featured_images[1];
        echo "<a href='{$image['full']}'>";
            echo "<img src='{$image['thumb']}' alt='Dynamic Featured Image' />";
        echo "</a>";
    }
 }
| improve this answer | |
  • Thanks for answer. Now Im not using child theme. As I understand, I just added this code to functions.php but still no result. Do I need to add something to other file like module-6.php wich I am using. Theme is link – Andrew11 Nov 10 '15 at 13:36
  • I tried that with no result just code appears in place for image. This is my template where I need to put it. this is the link : textsnip.com/jngte7 . thanks in advance. – Andrew11 Nov 10 '15 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.