Last active
March 20, 2021 02:24
-
-
Save rynaldos-zz/0a54362495c35a1850e80234350d2d5a to your computer and use it in GitHub Desktop.
[WooCommerce 3.0+] Remove links from single product image thumbnails
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_filter('woocommerce_single_product_image_thumbnail_html','wc_remove_link_on_thumbnails' ); | |
function wc_remove_link_on_thumbnails( $html ) { | |
return strip_tags( $html,'<img>' ); | |
} | |
//Did this help? Donate me some BTC: 1BEsm8VMkYhSFJ92cvUYwxCtsfsB2rBfiG |
Thanks @rynaldos and @pauloiankoski!
As of PHP 7.4.0 the line can be written as:
add_filter( 'woocommerce_single_product_image_thumbnail_html', 'wc_remove_link_on_thumbnails' );
function wc_remove_link_on_thumbnails( $html ) {
return strip_tags( $html, [ 'div', 'img' ] );
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello! Thank you very much for the function. It really helped. Guys, tell me, how can we make this function affect only the main image, and the screenshots (miniatures) open? Thank you in advance. For clarity, draw.)