php - Wordpress - loop image description
function the_post_thumbnail_caption() {
global $post;
$thumbnail_id = get_post_thumbnail_id($post->ID);
$thumbnail_image = get_posts(array('p' => $thumbnail_id, 'post_type' => 'attachment'));
if ($thumbnail_image && isset($thumbnail_image[0])) {
echo '<p>'.$thumbnail_image[0]->post_content.'</p>';
}
}
I've seen this code in the net. But it only displays the first image description that has been attached. I'm new in wordpress and still getting problems with coding. How can I put this inside a loop for it to display all the image description that has been attached. Thanks!
Answer
Solution:
Try this