Displaying image captions
-
Hello again!
I wonder if anyone can help me with this.
It seems like a simple thing to do, but I’ve been trying for hours now, and couldn’t get it to work.My custom post type is called ‘art’, and it has a ‘File / Image / Video’ custom field, where I can upload a single image file.
I managed to get the attachment ID, and the image alt text, but I wasn’t able to find how to get the image caption and/or description.This is the code so far (in single-art.php) :
$art = pods('art', get_the_id()); $a_id = $art->field('ID'); $img = get_post_meta( $a_id, 'a_img._src.full', true); $img_id = $art->field('a_img.ID', true); $img_alt = get_post_meta($img_id, '_wp_attachment_image_alt', true); $img_caption = get_post_meta($img_id, 'post_excerpt', true); echo '<img src="' . $img . '" Alt="' . $img_alt . '" />'; echo '<p>' . $img_caption . '</p>';
Any help will be much appreciated.
Thank you!!
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘Displaying image captions’ is closed to new replies.