Created
June 23, 2014 22:16
-
-
Save claudiosanches/f6be905c58d1a519bd2b to your computer and use it in GitHub Desktop.
WooCommerce - Just one thumbnail in product page.
This file contains 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
function custom_woocommerce_show_product_thumbnails() { | |
global $product; | |
$attachment_ids = $product->get_gallery_attachment_ids(); | |
if ( ! empty( $attachment_ids ) ) { | |
$attachment_id = current( $attachment_ids ); // pega o primeiro | |
$image_link = wp_get_attachment_url( $attachment_id ); | |
if ( ! $image_link ) { | |
return; | |
} | |
$image = wp_get_attachment_image( $attachment_id, apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' ) ); | |
$image_title = esc_attr( get_the_title( $attachment_id ) ); | |
echo sprintf( '<a href="%s" title="%s">%s</a>', $image_link, $image_title, $image ); | |
} | |
} | |
add_action( 'woocommerce_product_thumbnails', 'custom_woocommerce_show_product_thumbnails', 20 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment