我試圖從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隱藏圖像。我現在會爲你搜索鉤子:) –