0

我创建了一个自定义画廊滑块,我想将其连接到帖子和页面创建器内部的媒体上传画廊功能。

问题是我似乎无法理解如何从媒体上传库中获取原始 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="">

这甚至可能吗?我真的不想使用插件

4

1 回答 1

1

获取 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 );
}
于 2013-08-09T22:08:23.297 回答