我使用插图作为我的产品图片。但是,如果您单击产品档案中的插图,则会进入单个产品页面。在单个产品页面中,我想隐藏插图并显示真实图像。我从另一个论坛尝试过这个,但它不起作用......
add_filter( 'woocommerce_product_gallery_attachment_ids', 'so_31818331_filter_gallery', 10, 2 );
function so_31818331_filter_gallery( $ids, $product ){
if (is_product()) {
set_post_thumbnail( $post, $ids[0] );
unset($ids[0]);
}
else {
set_post_thumbnail( $post, end($ids));
}
return $ids;
}