How to get featured image of a product in woocommerce
I got the solution .I tried this .
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $loop->post->ID ), 'single-post-thumbnail' );?> <img src="<?php echo $image[0]; ?>" data-id="<?php echo $loop->post->ID; ?>">
The answers here, are way too complex. Here's something I've recently used:
<?php global $product; ?><img src="<?php echo wp_get_attachment_url( $product->get_image_id() ); ?>" />
Using wp_get_attachment_url()
to display the
I would just use get_the_post_thumbnail_url()
instead of get_the_post_thumbnail()
<img src="<?php echo get_the_post_thumbnail_url($loop->post->ID); ?>" class="img-responsive" alt=""/>