2016-07-12 5 views
0

좋아, 새로운 질문을하는 것이 허용되는지 여부는 알 수 없습니다. 하지만 제 이전 질문과는 조금 달랐습니다. (그렇지 않다면 말해주세요.)맞춤 분류 용어로 이미지 가져 오기

내 맞춤식 분류 용어에서 추천 이미지를 얻으려고합니다. 어제는 꽤 멀었지만 고객은 팀원의 이름을 추가하려고합니다. 그래서 저는 이것에 대한 드로잉 보드로 돌아 왔습니다.

내 테마는 4 개의 서로 접을 수있는 패널로 구성됩니다. 커스텀 포스트 타입과 루프.

그래서 모든 패널에 팀원을 표시하고 싶지 않기 때문에 맞춤 분류 ons_team을 만들었습니다. 그래서 나는 ctp상의 박스를 체크하여 팀원들을 보여주고 싶습니다.

이제 클라이언트가 다른 코드를 사용해야하는 팀 구성원의 이름을 추가하려고합니다. 어제 나는이 코드로 작업하게 만들었습니다.

<?php $terms = get_the_terms($post->ID , 'ons_team'); 
        print apply_filters('taxonomy-images-list-the-terms', '', array(
           'before'  => '<div class="ons-team">', 
           'after'  => '</div>', 
           'before_image' => '<span>', 
           'after_image' => '</span>', 
           'image_size' => 'detail', 
           'taxonomy'  => 'ons_team', 
          )); 
        foreach ($terms as $term) { 
         $term_link = get_term_link($term, 'ons_team'); 
         if(is_wp_error($term_link)) 
         continue; 


        } 
       ?> 

여기에는 상자를 선택한 패널의 팀원 만 표시됩니다. 그러나이 코드에 팀 구성원의 이름을 추가 할 수는 없습니다.

그래서 나는이 코드를 사용하여 한 페이지에 일을하는 데 :

<?php 
// List of image links 

$terms = apply_filters('taxonomy-images-get-terms', '', array('taxonomy' => 'ons_team')); 

foreach((array) $terms as $term) { 
echo '<div class="col s6 m6 l3 teamimage"><a href="' . esc_attr(get_term_link($term)) . '" title="' . sprintf(__("%s"), $term->name) . '" ' . '>' . wp_get_attachment_image($term->image_id, 'destacado-proyectos-home') . '</a>'; 

echo '<h2 class="truncate">' . sprintf(__("%s"), $term->name) . '</h2>'; 
    echo '</div>'; 
    } 
    ?> 

을하지만 패널에서 해당 코드를 사용하는 경우 I는 정보가 표시하고 싶습니다. 그것은 그것을 보여주고 자하는 유일한 패널이 아니라 모든 패널에 걸쳐 그것을 보여줍니다.

둘 모두의 조합을 사용해 보았지만 모든 패널에는 여전히 이미지와 이름이 표시됩니다.

<?php $terms = get_the_terms($post->ID , 'ons_team'); 
        $terms = apply_filters('taxonomy-images-get-terms', '', array('taxonomy' => 'ons_team')); 

          foreach((array) $terms as $term) { 
          echo '<div class="col s6 m6 l3 teamimage"><a href="' . esc_attr(get_term_link($term)) . '" title="' . sprintf(__("%s"), $term->name) . '" ' . '>' . wp_get_attachment_image($term->image_id, 'destacado-proyectos-home') . '</a>'; 
          echo '<h2 class="truncate">' . sprintf(__("%s"), $term->name) . '</h2>'; 
          echo '</div>'; 
          } 
        foreach ($terms as $term) { 
         $term_link = get_term_link($term, 'ons_team'); 
         if(is_wp_error($term_link)) 
         continue; 


        } 
       ?> 

foreach 또는 다른 장소 사이에 코드를두면 코드가 손상됩니다. $ term/$ terms을 많이 사용하기 때문에 이것이 작동하지 않을 수도 있습니까?

이런 식으로 사용 : ...

어떤 도움을 작품의

<?php $terms = get_the_terms($post->ID , 'ons_team'); 

        foreach ($terms as $term) { 
         $term_link = get_term_link($term, 'ons_team'); 
         $terms = apply_filters('taxonomy-images-get-terms', '', array('taxonomy' => 'ons_team')); 

          foreach((array) $terms as $term) { 
          echo '<div class="col s6 m6 l3 teamimage"><a href="' . esc_attr(get_term_link($term)) . '" title="' . sprintf(__("%s"), $term->name) . '" ' . '>' . wp_get_attachment_image($term->image_id, 'destacado-proyectos-home') . '</a>'; 
          echo '<h2 class="truncate">' . sprintf(__("%s"), $term->name) . '</h2>'; 
          echo '</div>'; 
          } 
         if(is_wp_error($term_link)) 
         continue; 


        } 
       ?> 

종류를하지만 그때는 연속 10 번 같은 팀 멤버를 표시하는 것은 많이 감사합니다!

답변

1

해결했습니다!

<div class="teamleden over-ons-ul"> 
       <div class="center-align"> 
        <div class="row"> 
         <?php 
         $terms = get_the_terms($post->ID , 'ons_team'); 

         if ($terms != null){ 
          $terms = apply_filters('taxonomy-images-get-terms', '', array('taxonomy' => 'ons_team')); 

            foreach((array) $terms as $term) { 
            echo '<div class="col s6 m6 l3 teamimage"><a href="' . esc_attr(get_term_link($term)) . '" title="' . sprintf(__("%s"), $term->name) . '" ' . '>' . wp_get_attachment_image($term->image_id, 'destacado-proyectos-home') . '</a>'; 
            echo '<h2 class="truncate">' . sprintf(__("%s"), $term->name) . '</h2>'; 
            echo '</div>'; 
            } 
         foreach($terms as $term) { 

         unset($term); 
         } } ?> 
        </div> 
       </div> 
      </div>  
+0

좋은 일 Steggie : 여기

은 사람들이 그것을 필요로하는 경우 올바른 코드 –

관련 문제