4
如何以编程方式显示产品图库中的图像?我看到了显示精选图像的选项;但不能显示产品ID的所有图像。Woocommerce通过产品ID获取图像画廊
可以做到这一点吗?
我尝试这个,但无法通过Woocommerce中的id从产品库中获取图像。
<?php
$gallery = get_post_gallery_images(724);
$image_list = '<ul id="cfImageGallery">';
foreach($gallery as $image) {// Loop through each image in each gallery
$image_list .= '<li><img src=" ' . str_replace('-150x150','',$image) . ' " /></li>';
}
$image_list .= '</ul>';
echo $image_list;
?>
谢谢你,这是适用于我:) –
get_gallery_attachment_ids()函数已弃用,因为woocommerce 3.0.0可以使用get_gallery_image_ids()。 –