I tried using suggestions from other posts but they do not work. I am looking to not show the featured product image in my product images area/image
gallery because I am using the featured image in the header as a background image and its too wide to be in the gallery.
So far this is the closest thing to working but I get an error. It does however do what I need.
Any way to fix this so i do not get the error?
Here is my code:
add_filter('woocommerce_single_product_image_thumbnail_html', 'remove_featured_image', 10, 3);
function remove_featured_image($html, $attachment_id, $post_id) {
$featured_image = get_post_thumbnail_id($post_id);
if ($attachment_id != $featured_image) {
return $html;
}
return '';
}
And here is the error:
Missing argument 3 for remove_featured_image() in /home/…/plugins/my-custom-functions/inc/php/functional.php(93) : eval()'d code on line 4
Warning: Missing argument 3 for remove_featured_image() in /home…/plugins/my-custom-functions/inc/php/functional.php(93) : eval()'d code on line 4
There is only 2 arguments for
woocommerce_single_product_image_thumbnail_html
filter hook.So you have to change a little bit your code to avoid the error, this way:
Code goes in function.php file of your active child theme (or theme) or also in any plugin file.
References for filter hook
woocommerce_single_product_image_thumbnail_html
:single-product/product-image.php
single-product/product-thumbnails.php