Skip to content
PHP

Change Loop Thumbnail HTML in shop page Woocommerce

A
Author
Jun 8, 2021 · 1 min read
Change Loop Thumbnail HTML in shop page Woocommerce

To change the loop thumbnail HTML in the shop page of WooCommerce, you can use the woocommerce_before_shop_loop_item_title hook. This hook is used to add content before the product title in the loop.

Here’s an example code snippet that demonstrates how to change the loop thumbnail HTML in the shop page of WooCommerce:

function loop_product_thumbnail() {
    // Remove product images from the shop loop
    remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 );
    // Adding something instead
    function wc_template_loop_product_replaced_thumb() {
        echo "Your text or Image ";
    }
    add_action( 'woocommerce_before_shop_loop_item_title', 'wc_template_loop_product_replaced_thumb', 10 );
}
add_action( 'woocommerce_init', 'loop_product_thumbnail');
A
Author

Author at The Creative Coders.

The monthly build log

One email a month. New posts, lessons, and the occasional strong opinion. No spam.