2016-11-17 3 views
0

enter image description here내가 ACF에서 워드 프레스

enter image description here

분류 필드에 여러 카테고리 링크를 추가해야합니다.

범주 링크를 만들려면 분류 필드를 만들고 제목은 이지만 프런트 엔드에는 표시되지 않습니다.

아무도 해결책을 찾도록 도와주세요. 여기 내 코드이지만, 는 작동하지 :

<ul> 

<?php foreach($terms as $term): ?> 

<a href="<?php echo get_term_link($term); ?>">View all '<?php echo $term->name; ?>' posts</a> 

<?php endforeach; ?> 

</ul> 

답변

1

어떻게 u는 $ 조건을 설정합니까?

이다이없는이 필드가 저장되는 ID를 설정해야 작동하는 경우 분류 필드

<?php 

$terms = get_field('taxonomy_field_name'); 

if($terms): ?> 

    <ul> 

    <?php foreach($terms as $term): ?> 

     <h2><?php echo $term->name; ?></h2> 
     <p><?php echo $term->description; ?></p> 
     <a href="<?php echo get_term_link($term); ?>">View all '<?php echo $term->name; ?>' posts</a> 

    <?php endforeach; ?> 

    </ul> 

<?php endif; ?> 

의 마크 업 :

$terms = get_field('taxonomy_field_name', $post_id);