admin管理员组文章数量:1432368
I need to woocommerce product gallery add class in latest item, if more than two pictures in the gallery do no need add the class to the last element, but if there are more than two images in the gallery - starting from three, need add the class to the last item, i have this code, code working and in latest item i can add class, but if less 3, dont know how:
<?php
global $product;
$attachment_ids = $product->get_gallery_attachment_ids();
$count = count($attachment_ids); $num = 0;
foreach( $attachment_ids as $attachment_id ) {
$thumbnail_url = wp_get_attachment_image_src( $attachment_id, 'full' )[0];?>
<li class="<?php if($num == $count-1){ ?><?php }else{ ?>small<?php }?>"><a class="product-images__list-item" href="<?php echo $thumbnail_url; ?>"><img src="<?php echo $thumbnail_url; ?>"></a></li>
<?php $num++;?>
<?php } ?>
本文标签: galleryAdd class to latest item Woocommerce
版权声明:本文标题:gallery - Add class to latest item Woocommerce 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745586733a2664952.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论