我试图从WooCommerce的商品页面和单品页面中有条件地删除产品图像。它将从单品中删除图像,而不是/ shop页面上的商品。WooCommerce;从商店页面和单品页面删除产品图像
//* 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;
}
你最好通过钩子去除图像,而不是通过CSS隐藏图像。我现在会为你搜索钩子:) –