小编Ben*_*ied的帖子

WooCommerce;从商店页面和单品页面删除产品图片

我正在尝试有条件地从 WooCommerce 的商店页面和单一产品页面中删除产品图像。它从单个产品中删除图像,但不删除 /shop 页面上的产品。

//* Conditionally remove the Featured Product Image from the single-product page
function remove_gallery_and_product_images() {
if ( is_product() && is_single(array(1092, 1093, 1094) ) ) {
  remove_action( 'woocommerce_before_single_product_summary', 
'woocommerce_show_product_images', 20 );
  add_filter('body_class', 'no_prod_imgs_class');
  }
}
  add_action('template_redirect', 'remove_gallery_and_product_images');

//* Add CSS for removed featured images from multiple specific product detail 
pages
function no_prod_imgs_class($classes) {
$classes[] = 'no-product-images';
return $classes;
}
Run Code Online (Sandbox Code Playgroud)

wordpress woocommerce

2
推荐指数
2
解决办法
1万
查看次数

标签 统计

woocommerce ×1

wordpress ×1