gpt4 book ai didi

php - 防止产品页面中的可点击图片,禁用产品图片链接

转载 作者:行者123 更新时间:2023-12-03 11:22:48 25 4
gpt4 key购买 nike

使用 Woocommerce 和我的 Storefront 子主题,我试图防止在单击单个产品图像时打开一个包含全尺寸图像的新页面的事实。
我希望图像不可点击,因此如果用户点击产品页面中的图像,则不会发生任何事情。
在我的子主题functions.php 中,以下代码可防止在灯箱中缩放和打开图像,但我想完全停用链接。

add_action( 'after_setup_theme', 'remove_hemen_theme_support', 100 );
function remove_hemen_theme_support() {
remove_theme_support( 'wc-product-gallery-zoom' );
remove_theme_support( 'wc-product-gallery-lightbox' );
}
我怎样才能做到这一点?

最佳答案

添加此过滤器,它应该删除您的超链接

function e12_remove_product_image_link( $html, $post_id ) {
return preg_replace( "!<(a|/a).*?>!", '', $html );
}
add_filter( 'woocommerce_single_product_image_thumbnail_html', 'e12_remove_product_image_link', 10, 2 );

关于php - 防止产品页面中的可点击图片,禁用产品图片链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64160112/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com