2015-06-12 121 views
0

我想显示所有附加到wordpress文章的图像,并将图像链接到图像来源以在光盒中打开它。我正在使用以下代码:获取Wordpress附件图片网址

<?php if (have_posts()) : while (have_posts()) : the_post();  
$args = array(
'orderby' => 'title', 
    'order' => 'ASC', 
    'post_type' => 'attachment', 
    'numberposts' => -1, 
    'post_status' => null, 
    'post_parent' => $post->ID, 
    'exclude' => get_post_thumbnail_id() 
); 
    $attachments = get_posts($args); 
    if ($attachments) { 
     foreach ($attachments as $attachment) { 
      echo '<div id="image"> <a rel="lightbox" href="'; 
      ??? 
      echo '">'; 
      echo wp_get_attachment_image($attachment->ID, 'full'); 
      echo '</a></div>'; 
      } 
    } 
endwhile; endif; ?> 

我已经尝试了很多事情,但我似乎无法检索只是源网址。

任何人都可以提供一些见解?

回答