Hello I've been struggling for ages trying to find a solution for this. Basically I just want to retrieve all images from a post and display a caption underneath. Here is the code i'm using:
<?php
$argsThumb = array(
'order' => 'DESC',
'post_type' => 'attachment',
'post_parent' => $post->ID,
'post_mime_type' => 'image',
'post_status' => null
);
$attachments = get_posts($argsThumb);
if ($attachments) {
foreach ($attachments as $attachment) {
echo '<div class="slideshow-content"><img src="'.wp_get_attachment_url($attachment->ID, 'thumbnail', false, false).'" /><div class="captions"><p>'.apply_filters('the_title', $attachment->post_title).'</p></div></div>';
}
}
?>
As you can see it currently displays the title, but not the caption. I have tried using: $caption = $attachment->post_excerpt; - but not exactly sure where to implement it and what I have tried doesn't work. Any help would be greatly appreciated!
$attachment->post_excert;
doesn't work for you?