Woocommerce get category image full size

Solution for : Woocommerce get category image full size
We can use this wp_get_attachment_image_src function to achieve the goal.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$prod_categories = get_terms( 'product_cat', array(
        'orderby'    => 'name',
        'order'      => 'ASC',
        'hide_empty' => true
    ));
 
    foreach( $prod_categories as $prod_cat ) :
        $cat_thumb_id = get_woocommerce_term_meta( $prod_cat->term_id, 'thumbnail_id', true );
        $shop_catalog_img = wp_get_attachment_image_src( $cat_thumb_id, 'full' );
        $term_link = get_term_link( $prod_cat, 'product_cat' );?>
 
         echo '<div>
';
   echo $prod_cat->name;
   echo '----';
   echo '<img src="'.$shop_catalog_img[0].'">';
         echo '</div>
';
     endforeach; wp_reset_query();

No comments:

Post a Comment