2013-02-16 36 views
0
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>'; 
    } 
} 

我已經看到了這個代碼在網絡中。但它只顯示已附加的第一個圖像描述。我是wordpress新手,仍然遇到編碼問題。我怎麼能把它放在一個循環中,以顯示所有附加的圖像描述。謝謝!WordPress的 - 循環圖像說明

回答

0

試試這個

<?php 
    function the_post_thumbnail_caption() { 
     global $post; 
     $childs = get_children(array('post_parent' => $post->ID)); 
     if($childs) { 
     foreach($childs as $child) { 
     echo '<p>'.$child->post_content.'</p>'; 
     } 
     } 
     } 
?>