You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除WordPress产品页面的商品图片悬停缩放效果?

禁用WooCommerce产品图片悬停缩放效果的解决方法

你用的代码没生效,大概率是钩子时机不对,或是主题添加缩放支持的优先级比你的代码高。试试下面几种方法:

  • 调整钩子优先级与时机
    把代码改成这样,用after_setup_theme钩子并提高优先级,确保在主题完成设置后再移除缩放支持:

    function remove_image_zoom_support() {
        remove_theme_support( 'wc-product-gallery-zoom' );
    }
    add_action( 'after_setup_theme', 'remove_image_zoom_support', 99 );
    

    把这段代码加到主题的functions.php文件里,或是用代码片段插件添加。

  • 用CSS强制禁用
    如果是主题自定义的缩放效果(非WooCommerce原生),直接用CSS覆盖:

    /* 取消图片悬停缩放变换 */
    .woocommerce-product-gallery__image:hover img {
        transform: none !important;
        transition: none !important;
    }
    /* 隐藏WooCommerce原生的缩放层 */
    .woocommerce-product-gallery__image .zoomImg {
        display: none !important;
    }
    

    这段CSS可以加到「外观」→「自定义」→「额外CSS」里。

  • 禁用缩放脚本
    如果上面的方法都没用,直接取消加载WooCommerce的缩放脚本:

    function disable_woocommerce_zoom_script() {
        wp_dequeue_script( 'zoom' );
    }
    add_action( 'wp_enqueue_scripts', 'disable_woocommerce_zoom_script', 100 );
    

内容的提问来源于stack exchange,提问作者Hamza Afridi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 18:43:24