How to get featured image of a product in woocommerce

Please tell me where I am going wrong . Product featured image is not showing up.

   $args = array( 'post_type' => 'product', 'posts_per_page' => 80, 'product_cat' => 'profiler', 'orderby' => 'rand' );

    $loop = new WP_Query( $args );

   while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>

    <div class="dvThumb col-xs-4 col-sm-3 col-md-3 profiler-select profiler<?php echo the_title(); ?>" data-profile="<?php echo $loop->post->ID; ?>">

    <img src="<?php  get_the_post_thumbnail($loop->post->ID); ?>" data-id="<?php echo $loop->post->ID; ?>">

    <p><?php the_title(); ?></p>

    <span class="price"><?php echo $product->get_price_html(); ?></span>                    
    </div>

I have already added a featured image in back end

Solutions

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 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; ?>">

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=""/>

Similar questions

"Use as featured image" not working , "Set Featured Image" hangs. GoDaddy Issue
What my site runs on: What happens when i click use as featured image ? What I tried The problem was on 3.4.1 so i updated it to 3.4.2 ( Issue not resolved ) Changed the theme to the basic twenty ten ( Issue not resolved ) Wordpress support forums seem to sway towards the fact that its a wordpress core code issue and not an issue with the themes.
Posts without featured image using other post's featured image
I am using the following code (see bottom) to display a custom post called 'artists'. I am also using <?php if (has_post_thumbnail( $post->ID ) ) so I can set the background of a div using the post thumbnail (I don't think this is the problem). I want to display all of the posts on one page so use 'numberposts' => -1,. I have noticed that ...
Converting a themes featured image to WordPress featured image
I have a website that I am updating, it has over 400 posts so updating these manually isn't a very good option. The theme that was used is no longer supported, it has a custom field setup for the featured image. I want to convert that featured image to the WordPress featured image. How can I do this? In the database, the url for the images are stor...
wordpress-theme 2017: featured image behaviour: where to set the height of the featured image?
good day dear community, after having nailed down several issues with the set up of the theme twentyseventeen - the question today is: wordpress-theme 2017: featured image behaviour: where to set the height of the featured image!? Well while i was doing a little google-search i have found the following; I have been searching on the whole net in ord...
outputting a featured image rather than a link to a featured image
In the past, I used this custom function to create an image carousel on my WordPress blog with Thesis theme It has been a while since I used the code, and, having recently setup a new WordPress blog, I discovered it doesn't work anymore, in that the image isn't getting displayed with the link to the post. Someone suggested to me that this might be ...
Wordpress Setting Featured Image Size and Adding link to featured image and Title
I've created a filterable portfolio in wordpress followindg a quicksand tutorial I found. Everything is working but the author did not link the featured image in the page template nor set the thumbnail size for the post type. I want the thumbnail size to be 280px x 180px. Here is the code: (Edited working code below)

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.