Hi I have a snippet that is supposed to replace the default archive thumbnails with a new one.
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
add_action( 'woocommerce_before_shop_loop_item_title', 'vista_replace_product_thumbnail', 10 );
function vista_replace_product_thumbnail() {
global $product;
$attachment_id = $product->get_gallery_attachment_ids(
array(
'orderby' => 'rand', //random order
)
)[0];
echo "<img src='" . wp_get_attachment_url( $attachment_id ) . "'>";
}
The following line is failing to remove the existing thumbnails. But the rest of the code is working.
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
Does the enfold product archive page replace woocommerce_template_loop_product_thumbnail with a different action name?
I cannot think of another reason why this would fail to remove the thumb.
Hey Thomas,
Thank you for the inquiry.
You may also need to remove this action in order to override the default product thumbnails on the archive pages.
add_action( 'woocommerce_before_shop_loop_item_title', 'avia_woocommerce_thumbnail', 10 );
Best regards,
Ismael