Remove Links From Single Product Image Thumbnails

Recommendation

Learn why I switched to WPCodeBox for managing code snippets for myself and for my clients.

Instructions

Snippet Type: PHP

  1. Copy the snippet.
  2. Add the snippet using WPCodeBox.
  3. Follow any customization notes provided.
  4. Save the snippet.
  5. Enable the snippet.
  6. Test.

Snippet

When people visit your Single Product pages, they may click on your product’s thumbnail image, which in turn pulls up a lightbox for that image.

This may be undesirable for some website owners, so that is where this code snippet comes in.

				
					// REMOVE LINKS FROM SINGLE PRODUCT IMAGES
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>' );
}