Home Forums Add-ons Gallery Field display first gallery picture on archive page Reply To: display first gallery picture on archive page

  • For anyone else looking for this I’ve found a solution, probably not the best but it works!

    The featured image code higher in the page sets an ‘$image_url’ here:

    $image_id = get_post_thumbnail_id();
    $image_url = wp_get_attachment_image_src($image_id,’large’);
    $image_url = $image_url[0];

    echo ‘‘;


    echo ‘‘; ?>

    Then I just compare the gallery image to that and hide if they are the same

    <?php $images = get_field(‘image_gallery’);
    if( $images ) { ?>
    <div id=”imagegallery”>

    <?php foreach( $images as $image ) {

    if ($image_url != $image[‘url’]) {
    ” rel=”shadowbox[gallery]” >” alt=”<?php echo $image[‘alt’]; ?>” class=”alignleft” />

    <?php } //End URL Check (to hide featured in gallery)
    } // End image loop ?>

    <?php } ?>

    UPDATE – Editor has made a bit of a mess of the above, but you get the principal!