WordPress.org

Ready to get started?Download WordPress

Forums

DIsplay Image Caption - Advanced Custom Field Repeater. (1 post)

  1. surfsup74
    Member
    Posted 1 year ago #

    I would like to display the image's (attachment's) 'caption' in an Advanced Custom Fields repeater image field. From what I've read the 'caption' is stored as the attachment's 'post_excerpt' however I don't know how to get that and insert it in my current code (below). Thanks.

    <?php if(get_field('images')): ?>
    <?php while(the_repeater_field('images')): ?>
    <?php $image = wp_get_attachment_image_src(get_sub_field('image'), 'large'); ?>
    <?php $PostImage = wp_get_attachment_image_src(get_sub_field('image'), 'thumbnail'); ?>
    <a title="View large image" href="<?php echo $image[0]; ?>" >
    <img src="<?php echo $PostImage[0]; ?>" alt="<?php echo ADD IMAGE CAPTION HERE PLEASE! ?>" />
    </a>
    <?php endwhile; ?>
    <?php endif; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic