我已经创建了一个自定义图库滑块,我想将其连接到帖子和页面创建者内部的媒体上传图库功能。
问题是,我似乎不明白如何从媒体上传库中获得原始URL循环,因为如果我现在使用媒体上传功能添加图像,它会给我一个看起来像这样的输出。
<div id="gallery-1" class="gallery galleryid-81 gallery-columns-9 gallery-size-thumbnail"><dl class="gallery-item">
<dt class="gallery-icon landscape">
<a href="url.com" title="jay-z+2"><img width="150" height="150" src="#" class="attachment-thumbnail" alt=""></a>
</dt></dl><dl class="gallery-item">
<dt class="gallery-icon landscape">
<a href="#" title=""><img width="150" height="150" src="#" class="attachment-thumbnail" alt=""></a>
</dt></dl><dl class="gallery-item">
<dt class="gallery-icon landscape">
<a href="url.com" title=""><img width="150" height="150" src="#" class="attachment-thumbnail" alt=""></a>
</dt></dl>
</div>
我想要一些类似的东西
<img width="150" height="150" src="#" class="attachment-thumbnail" alt="">
<img width="150" height="150" src="#" class="attachment-thumbnail" alt="">
<img width="150" height="150" src="#" class="attachment-thumbnail" alt="">
这可能吗?我真的不想使用插件
获取url-运行查询
$query_images_args = array(
'post_type' => 'attachment', 'post_mime_type' =>'image', 'post_status' => 'inherit', 'posts_per_page' => -1,
);
$query_images = new WP_Query( $query_images_args );
$images = array();
foreach ( $query_images->posts as $image) {
$images[]= wp_get_attachment_url( $image->ID );
}