Answers for "wc get product image"

3

get product image woocommerce

// Use $post->ID to get from post object
$id = $loop->post->ID
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $id ), 'single-post-thumbnail' );

<img src="<?php echo $image[0]; ?>" data-id="<?php echo $id; ?>" />
Posted by: Guest on May-04-2020
1

wc get product image

<?php global $product; ?>
<img src="<?php echo wp_get_attachment_url( $product->get_image_id() ); ?>" />
Posted by: Guest on June-28-2021
0

wc get product category image

<?php
        if ( is_product_category() ){

            global $wp_query;
            $cat = $wp_query->get_queried_object();    
            $thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true ); 
            $image = wp_get_attachment_url( $thumbnail_id ); 
            echo "<img src='{$image}' alt='' />";
        }
    ?>
Posted by: Guest on June-29-2021

Browse Popular Code Answers by Language