Hello,
I am wondering if it is possible to get custom fields assigned to the post thumbnail on a post. For example, in WordPress you can grab the post thumbnail caption. I am trying to grab custom text areas assigned to images
<?php if ( $caption = get_post( get_post_thumbnail_id() )->post_excerpt ) : ?>
<?php echo $caption; ?>
<?php endif; ?>
You need to supply the $post_id value in get_field()
<?php
$attachment_id = get_post_thumbnail_id();
$value = get_field('field_name', $attachment_id);
?>
Thanks, this worked perfectly!