问题
I am trying to remove the image zoom from my custom themed website which uses WooCommerce. Here is what I've tried adding in my functions.php file:
add_action( 'after_setup_theme', 'remove_pgz_theme_support', 100 );
function remove_pgz_theme_support() {
remove_theme_support( 'wc-product-gallery-zoom' );
}
and this
add_action( 'wp', 'remove_pgz_theme_support', 20 );
function remove_pgz_theme_support() {
remove_theme_support( 'wc-product-gallery-zoom' );
}
I've spend some time googling but the answers always recommend trying something along the lines of the above.
回答1:
I disable all image effects with:
add_action('wp', 'remove_woo_image_effects');
function remove_woo_image_effects() {
// this should be disable the gallery slider and lightbox
remove_theme_support('wc-product-gallery-lightbox');
remove_theme_support('wc-product-gallery-slider');
// this should be disable the zoom
remove_theme_support('wc-product-gallery-zoom');
}
I tested it with DIVI and two from my custom themes
checked it here with custom theme
回答2:
The solution that worked for me is adding the following to your functions.php file
// Add WooCommerce support
function add_woocommerce_support() {
add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'add_woocommerce_support' );
来源:https://stackoverflow.com/questions/50704326/cant-remove-woocommerces-image-zoom