2013-05-29 52 views
0
$argsThumb = array(
    'order'   => 'ASC', 
    'post_type'  => 'attachment', 
    'post_parent' => $post->ID, 
    'post_mime_type' => 'image', 
    'post_status' => null 
); 
$attachments = get_posts($argsThumb); 
if ($attachments) { 
    foreach ($attachments as $attachment) { ?> 

    <div class="item"> 
     <a href="<?php wp_get_attachment_url($attachment->ID, 'large', false, false); ?>" class="zoom" rel="group"> 
      <span class="thumb"> 
       <img class="small" src="<?php wp_get_attachment_url($attachment->ID, 'medium', false, false); ?>" /> 
      </span> 
     </a> 

    </div> 

<?php } } ?> 
+1

什麼這個問題?你的代碼片段不起作用?有錯誤嗎?它會返回任何東西嗎? – montrealist

回答

1

wp_get_attachment_url僅採用一個參數+你需要回應:

<?php echo wp_get_attachment_url($attachment->ID); ?>

注:獲得特定的圖像大小,使用wp_get_attachment_image_src

+0

但附件圖像顯示,問題是所有媒體圖像文件都顯示。我只想在那篇文章中 – ram

相關問題