• djdrogba

    (@djdrogba)


    Hi everyone,

    my posts are containing two attachment image that I would like to display in 2 different divs.

    Since I am a noob in PHP, I’ve found a code that works well to get the first attachment image:

    <?php
    $attachments = get_children(array('post_parent' => get_the_ID(), 'post_type' => 'attachment', 'post_mime_type' => 'image', 'orderby' => 'menu_order'));
    if ( ! is_array($attachments) ) continue;
    $count = count($attachments);
    $first_attachment = array_shift($attachments);
    ?>
    <?php echo wp_get_attachment_image($first_attachment->ID); ?>

    Anyone knows how to get the second attachment image???

    Thx in advance

  • The topic ‘Display the second attachment image of a post’ is closed to new replies.