2017-10-26 4 views
1

특별한 갤러리를 위해 모든 woocommerce 변형 이미지를 보여줄 필요가 있습니다. woocommerce content-single-product.php에서 유사 콘텐츠에 액세스 할 수 있지만 이미지 URL을 가져올 수 없습니다. 내가 어떻게 할 수 있니? 내 콘텐츠 - 단일 product.php 덮어 내부Woocommerce 단일 제품 페이지 - 모든 변형 이미지보기

:이 같은 뭔가를 할 수

<?php 

    $args = array(
     'post_type'  => 'product_variation', 
     'post_status' => array('private', 'publish'), 
     'numberposts' => -1, 
     'orderby'  => 'menu_order', 
     'order'   => 'asc', 
     'post_parent' => $post->ID 
    ); 

    $variations = get_posts($args); 

    echo "<pre>"; print_r($variations); echo "</pre>"; 

?> 

답변

0

.

$product = new WC_Product_Variable($product_id); 
// get the product variations 
$product_variations = $product->get_available_variations(); 

if (!empty($product_variations)) { 
    foreach($product_variations as $product_variation) { 
     echo $product_variation['image_src']; 
    } 
} 
관련 문제