Skip to content

Instantly share code, notes, and snippets.

@claudiosanches
Created June 23, 2014 22:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claudiosanches/f6be905c58d1a519bd2b to your computer and use it in GitHub Desktop.
Save claudiosanches/f6be905c58d1a519bd2b to your computer and use it in GitHub Desktop.
WooCommerce - Just one thumbnail in product page.
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