我想用我购买的WooCOmmerce主题中的Slide替换每个产品的产品图片。不幸的是,滑块仅从我没有上传任何图片的产品图库中获取图片。我为每个产品上传的唯一图片被设置为产品图片。我还想将滑块中的产品图像图片用作主要图像和唯一图像。
我认为可以在此代码中对其进行编辑,但是很不幸,我不知道如何操作。有人可以帮我吗?
<?php
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $post, $woocommerce, $product;
$attachment_ids = $product->get_gallery_attachment_ids();
?>
<div class="images">
<?php if ( $attachment_ids ) : ?>
<div class="big flexslider">
<ul class="slides">
<?php
$loop = 0;
$classes = array( 'zoom' );
foreach ( $attachment_ids as $attachment_id ) {
$image_link = wp_get_attachment_url( $attachment_id );
if ( ! $image_link )
continue;
$attachment_count = count( $product->get_gallery_attachment_ids() );
if ( $attachment_count > 0 ) {
$gallery = '[product-gallery]';
} else {
$gallery = '';
}
$image = wp_get_attachment_image( $attachment_id, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) );
$image_title = esc_attr( get_the_title( $attachment_id ) );
echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', sprintf( '<li><a href="%s" title="%s" class="%s" data-rel="prettyPhoto' . $gallery . '">%s</a></li>', $image_link, $image_title, implode( ' ', $classes ), $image ), $attachment_id, $post->ID );
$loop++;
}
?>
</ul>
</div>
<?php endif; ?>
<?php do_action( 'woocommerce_product_thumbnails' ); ?>
</div>