Skip to content

Instantly share code, notes, and snippets.

@AntoscencoVladimir
Last active May 4, 2016 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AntoscencoVladimir/68ff611de2e054ea54dc1f1f42038e8c to your computer and use it in GitHub Desktop.
Save AntoscencoVladimir/68ff611de2e054ea54dc1f1f42038e8c to your computer and use it in GitHub Desktop.
WooCommerce insert wrapper around thumbnail images in loop -------- Insert in functions.php file
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
add_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
if ( ! function_exists( 'woocommerce_template_loop_product_thumbnail' ) ) {
function woocommerce_template_loop_product_thumbnail() {
echo woocommerce_get_product_thumbnail();
}
}
if ( ! function_exists( 'woocommerce_get_product_thumbnail' ) ) {
function woocommerce_get_product_thumbnail( $size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0 ) {
global $post, $woocommerce;
$output = '<div class="imagewrapper">';
if ( has_post_thumbnail() ) {
$output .= get_the_post_thumbnail( $post->ID, $size );
}
$output .= '</div>';
return $output;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment