2014-12-05 6 views
0

현재 ACF 5를 사용 중입니다. 제품 카테고리에 리피터를 설정했습니다.고급 사용자 정의 필드 제품 카테고리 (woocommerce) 내의 리피터

저는 현재 정보를 출력하는 방법에 어려움을 겪고 있습니다. 나는 acrhive-제품 루프 내에서, 그리고 난 출력됩니다 내용이 들어있는 다음과 같은 템플릿을 업데이트하고있다 : 나는 리피터에 대한 각 루프에 대해 다음 한

내용 product_cat.php에서
<?php while (have_posts()) : the_post(); ?> 

    <?php wc_get_template_part('content', 'product_cat'); ?> 

<?php endwhile; // end of the loop. ?> 

. 모든 기본 정보가 이미 표시되어 있습니다. 제목, woocommerce 카테고리 이미지 등. 리피터를 추가하면 카테고리 자체에 추가 할 수 없습니다.

<?php 
    $terms = get_field('attributes', 'product_cat_'.$term->term_id); 
    if($terms): ?> 
     <ul> 
    <?php foreach($terms as $term): ?> 
      <li> 
      <?php the_sub_field('attribute'); ?> 
      </li> 
    <?php endforeach; ?> 
     </ul> 
     <?php endif; ?> 

어떤 생각이 크게 먼저 인수 인쇄

+0

당신이 있습니까'WP_DEBUG '가능하게 되었습니까? 당신이 원할 수도 있습니다. 정의되지 않은 객체/변수가있는 경우 적어도이를 알 수 있습니다. '$ term-> term_id'를 어떻게 정의하고 있습니까? 나는'term'없이'foreach()'루프에 들어 가지 않을 것이기 때문에 거기에서 시작할 것입니다. 그 후 ACF에 대해 충분히 알지 못합니다. – helgatheviking

답변

0

을 감상 할 수있다 :

<?php print_r($category);?> 

그런 다음 다음과 같은 생산하기 위해 출력을 사용 :

<?php 
     $cat_id = $category->term_id; //used below to get a the acf from the categories! 
    ?> 


<?php 
     // $cat_id = $category->term_id; 

     $terms_features = get_field('features', 'product_cat_'.$cat_id); 
     if($terms_features): 
      // print_r($terms_features); 
     ?> 
     <ul> 
     <?php foreach($terms_features as $terms_feature): 
     // print_r($term); 
     ?> 
     <?php 
      $image_icon = $terms_feature['icon']; 
      $image_icon_show = $image_icon[sizes][large]; 
      // print_r($image_feature); 
     ?> 
       <li> 
        <img src="<?php echo $image_icon_show;?>" /> 
        <?php echo $terms_feature['description'];?> 
       </li> 
     <?php endforeach; ?> 
     </ul> 
     <?php endif; ?> 
관련 문제