2016-06-09 56 views
1

您好我有投資組合的博客,並在投資組合頁面,我告訴我的圖片作爲形象飼料,並通過畫廊增添了節目根本就沒有超鏈接沒有標題沒有標題如何顯示在多媒體圖像標題的WordPress

我想說明每幅圖像

這裏唯一的標題是代碼中使用我的主題來顯示圖像

<?php 
    global $post; 
    $header_images = get_post_meta($post->ID, '_ebor_gallery_images', 1); 

    if(is_array($header_images)) : 
?> 

<ul class="basic-gallery text-center"> 
    <?php 
     foreach($header_images as $id => $content){ 
      echo '<li>'. wp_get_attachment_image($id, 'large') .'</li> '; 

     } 
    ?> 
</ul> 

如何在此添加標題幫我出這個

謝謝!

+0

請添加一個$ header_images var_dump,在那裏我想你會看到所需的屬性 – niklas

+1

可能重複的[Wordpress獲取附件圖像標題](http://stackoverflow.com/questions/34658739/wordpress-get-attachment-圖片標題) –

+0

看看http://stackoverflow.com/questions/34658739/wordpress-get-attachment-image-caption我的答案在這裏有效 –

回答

0

在你foreach

$attachment_title = get_the_title($id) 

應該讓你的標題。

0

嘗試......

<ul class="basic-gallery text-center"> 
    <?php 
     $output = ''; 
     foreach($header_images as $id => $content){ 
      $output .= '<li>'. wp_get_attachment_image($id, 'large'); 
      $image = get_post($id); 
      $output .= '<span class="caption>'.$image->post_excerpt.'</span>'; 
      $output .= .'</li> '; 
     } 
     echo $output; 
     $output = ''; 
    ?> 
</ul> 

輸出你在任何你想要的容器標題,我只是用一個跨度的例子。

+0

僅供參考除圖像是標題 –

+0

但這裏那些標題來了,我們通過畫廊選項添加這樣每個圖像不同的標題,所以我在輸出中使用@Simon Pollard –

+0

the_excerpt ();這段作品的摘錄和顯示什麼爲標題@Simon Pollard –

相關問題