【发布时间】:2014-06-25 13:06:09
【问题描述】:
我正在使用此代码将所有图像上传到页面,它工作正常,但我想将图像 URL 用于灯箱功能,目前我得到一个 img 对象。有什么办法可以专门获取图片网址吗?我想认为它是数组的一部分。这是我正在使用的代码:
<?php
$images = get_children( array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'orderby' => 'menu_order',
'order' => 'ASC',
'numberposts' => 999 ) );
if ( $images ) {
//looping through the images
foreach ( $images as $attachment_id => $attachment ) {
?>
<li>
<a href="*the_img_url*" data-lightbox="lightbox-1" data-title="<?php echo $attachment->post_excerpt; ?>" ><?php echo wp_get_attachment_image( $attachment_id, 'full' ); ?>
</a>
</li>
<?php
}
}
?>
谢谢。
【问题讨论】: