它显示不正确。lightbox很光滑,但我尝试在没有它的情况下使用它,所以它不是lightbox导致错误工作的原因。我想要的是准确的编码,而不是插件。
php部分,我在其中显示库
add_action( 'woocommerce_before_shop_loop_item_title', ' themename_loop_product_div_image_open', 5);
function themename_loop_product_div_image_open(){
?>
<div class="wrap-loop-img-item">
<?php
global $product;
$attachment_ids = $product->get_gallery_attachment_ids();
if ( ! empty( $attachment_ids ) ) {
foreach( $attachment_ids as $attachment_id ) {?><div class="slider-item"><?php
echo wp_get_attachment_image( $attachment_id, 'woocommerce_thumbnail' )?></div><?php ;
}}else{
$attachment_id = get_post_thumbnail_id( $product->get_id() );
$product_thub = wp_get_attachment_image_url($attachment_id, 'woocommerce_thumbnail'); ?>
<img src="<?php echo $product_thub;?>" alt="">
<?php
}
?>
<?php }
add_action( 'woocommerce_before_shop_loop_item_title', ' themename_loop_product_div_image_close', 30);
function themename_loop_product_div_image_close(){
?>
</div>
<?php }
js部分
jQuery('.wrap-loop-img-item').each(function() {
var slider = jQuery(this);
slider.slick({
infinite: true,
slidesToShow: 1,
slidesToScroll: 1,
dots:false,
arrows: false,
driggable:false,
swipe: false,
swipeToSlide: false,
touchMove: false,
});
var sLightbox = jQuery(this);
sLightbox.slickLightbox({
src: 'src',
itemSelector: '.img.attachment-woocommerce_thumbnail.size-woocommerce_thumbnail',
});
});
也许你知道我哪里出错了?或者我不知道一些我必须知道的事情。
暂无答案!
目前还没有任何答案,快来回答吧!