Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Woocommerce remove link on featured image

I'm trying to remove the link on the featured image when I add a new product in Woocommerce. I did it in the previous version but since updating I can't seem to find how/where I edited it. Trying to look through some files to no avail. Any help?

like image 280
vytfla Avatar asked Jul 25 '13 04:07

vytfla


People also ask

Can a link be added to WP featured images?

On WordPress.com it's not possible to add a link directly to a featured image, but featured images should by default link to the post where they appear in the main feed of the site. If I view your site's feed at https://toosanguine.wordpress.com/blog/ every featured image is linking to the post, same as the post title.

How do I change the featured image URL in WordPress?

Click on the settings icon at the top of the page. By default, you will start in the Block section. Click on the Document section. Scroll down until you have found the Featured Image from URL option.


1 Answers

I originally used css: pointer-events:none;

On the link class (I think I used .zoom img) however I needed to use the image for a jQuery zoom so after hours of searching I found this solution, just add this to your functions.php and it will sort you out.

/**
  * Remove link wrapping main product image in single product view.
  * @param $html
  * @param $post_id
  * @return string
*/

function custom_unlink_single_product_image( $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_unlink_single_product_image', 10, 2);
like image 199
Charlie Tupman Avatar answered Oct 09 '22 18:10

Charlie Tupman