Display data from custom field from attached image in post
-
Hi all,
I found a way to add custom fields to an attached photo but I don’t know how to display the input from those fields. I have a custom field called ‘photocredits’ and want to display the data from that custom field in the image, just like a caption.I’m using this to display the image:
<?php $thumb_id = get_post_thumbnail_id($post->id); $args = array( 'post_type' => 'attachment','post_status' => null,'post_parent' => $post->ID,'include' => $thumb_id); $thumb_images = get_posts($args); foreach ($thumb_images as $thumb_image) { if($thumb_image->[customfield]) echo '<h2><span>','Image: ' . $thumb_image->[customfield] . '</h2></span>'; } ?>
and [customfield] is where data from the custom field is to be displayed.
Any help would be greatly appreciated.
Thanks,
Gregory S.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Display data from custom field from attached image in post’ is closed to new replies.