Skip to content

Instantly share code, notes, and snippets.

@rynaldos-zz
Last active March 20, 2021 02:24
Show Gist options
  • Save rynaldos-zz/0a54362495c35a1850e80234350d2d5a to your computer and use it in GitHub Desktop.
Save rynaldos-zz/0a54362495c35a1850e80234350d2d5a to your computer and use it in GitHub Desktop.
[WooCommerce 3.0+] Remove links from single product image thumbnails
@marcelo2605
Copy link

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

@pauloiankoski
Copy link

pauloiankoski commented Mar 21, 2018

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>' );
}

@jmurphree77
Copy link

@pauloiankoski - good job, works great over here!

@hipimps
Copy link

hipimps commented Oct 28, 2018

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.)
screen

@Dadntiney
Copy link

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.)
screen

Is there a solution for this? Thnx,

@baras
Copy link

baras commented Oct 8, 2020

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' ] );
}

@HadalyVillasclaras
Copy link

Hi, It seem it also works one my site but I don't know why the featured image is duplicate now ! Any clue about that?
Cheers
Captura de pantalla 2020-10-10 a las 13 11 01
Captura de pantalla 2020-10-10 a las 13 11 10
Captura de pantalla 2020-10-10 a las 13 11 18

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment