Forked from ben-heath/custom-woocommerce-shop-loop-thumbnail-and-title.php
Created
December 27, 2025 05:24
-
-
Save jamiemitchell/0c7e1650bd1e55ea9de7ae922b4524d2 to your computer and use it in GitHub Desktop.
Custom WooCommerce Shop Loop Product Thumbnail and Title
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Check if WooCommerce is active | |
| **/ | |
| if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { | |
| // remove product thumbnail and title from the shop loop | |
| remove_action( 'woocommerce_shop_loop_item_title', 'woocommerce_template_loop_product_title', 10 ); | |
| remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10 ); | |
| // add the product thumbnail and title back in with custom structure | |
| add_action( 'woocommerce_before_shop_loop_item_title', 'sls_woocommerce_template_loop_product_thumbnail', 10 ); | |
| function sls_woocommerce_template_loop_product_thumbnail() { | |
| echo '<a class="thumbnail" title="'.get_the_title().'" href="'. get_the_permalink() . '">'.woocommerce_get_product_thumbnail().'</a>'; | |
| echo '<h3><a href="'.get_the_permalink().'">'.get_the_title().'</a></h3>'; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment