• Resolved theotheo

    (@theotheo)


    I am editing the content-product.php (product loop) and i am trying to get the image url to use it in background-image css property.

    My code looks like this:
    <div class="loop-product-image" style="background-image: url('<?php How do i call the image url here ?>'); "> test </div>

    Can anybody help?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter theotheo

    (@theotheo)

    Resolved it myself. For anyone interested here is how to do it:

    <?php 
    $id = wc_get_product( $product_id );
    $image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );
    ?>

    <div class="loop-product-image" style="background-image: url('<?php echo $image[0]; ?>'); "> test </div>

    That’s great ?? thanks for letting us know!

    I’ll mark this thread as resolved now. If you have any further questions, I recommend creating a new thread.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get product image url in woocommerce shop page loop’ is closed to new replies.