The single product featured image in WooCommerce is clickable. I have been told that one has to use the theme code to disable the html link.
Test page: https://designkurs.com/kooperativet/produkt/bli-medlem/
The featured image is clickable. How do I remove the link from it?
Thank you.
Try this ... add the below code snippet in your functions.php file and let me know if it works or not ...
function custom_codefactry_single_product_image_html( $html, $post_id ) {
return get_the_post_thumbnail( $post_id, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ) );
}
add_filter('woocommerce_single_product_image_html', 'custom_codefactry_single_product_image_html', 10, 2);
Hey
I tested the above code on a local dev site and an online test site and it has no effect.
The following CSS works in hiding the mouse pointer making the single product featured image not clickable.
.woocommerce div.product div.images .woocommerce-product-gallery__wrapper {
pointer-events: none;
}
I know this question has been sitting for over a year, but I had the same issue. I found that this code worked for me:
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 );
Thanks for sharing Jim!
Great thoughts, I thank you for the useful materials.