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 |
Same problem here. Page return this:
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'wc_remove_link_on_thumbnails' not found or invalid function name in /var/www/public/wp-includes/class-wp-hook.php on line 300
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>' );
}
@pauloiankoski - good job, works great over here!
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
Same problem here, variation images stop working. Looking forward to updated code; thx :-)