php - Wordpress - loop image description -
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 code in net. displays first image description has been attached. i'm new in wordpress , still getting problems coding. how can set within loop display image description has been attached. thanks!
try this
<?php function the_post_thumbnail_caption() { global $post; $childs = get_children(array('post_parent' => $post->id)); if($childs) { foreach($childs $child) { echo '<p>'.$child->post_content.'</p>'; } } } ?>
php wordpress
Comments
Post a Comment