如何获取gallery里面的图片及id并遍历出来
Published
2022-05-11
浏览次数 : 163
<div class="g-context">
<?php
$gallery = get_post_gallery( get_the_ID(),false );
$gallery_image_ids = explode(',', $gallery['ids']);
echo "<pre>";
var_dump($gallery_image_ids);
echo "</pre>";
foreach ($gallery_image_ids as $id) :
$image = wp_get_attachment_image_src( $id,'customerThumbnail' );
echo "<pre>";
var_dump($image[0]);
echo "</pre>";
?>
<?php endforeach; ?>
</div>
- 标签1
- 标签1
- 标签1