2017-10-04 12 views
0

다음은 모든 용어를 나열합니다. 현재/현재 페이지를 제외한 모든 용어를 표시하도록 개정 할 수 있습니까? 고맙습니다.현재 페이지를 제외한 모든 조항 표시

$terms = get_terms('topics', array( 
'orderby' => 'name', 
'order' => 'ASC', 
)); 
if (! empty($terms)){ 
    foreach ($terms as $term) { 
     $term_thumb = get_field('image', $term); 
     echo '<li><a href="'.esc_url(get_term_link($term->term_id)) .'"><img src="' .$term_thumb['url']. '"><span class="model">'.$term->name .'</span></a></li>'; 
    } 
} 

답변

0

당신은 같은 것을 수행 할 수 있습니다

// create an empty array holder 
    $current_tax_ids = array(); 

    // get the post terms 
    $current_tax = get_the_terms($post->ID, 'topics'); 

    // creating loop to insert ids 
    foreach($current_tax as $tax) { 
     $current_tax_ids[] = $tax->term_id; 
    } 

    $args = array(
     'taxonomy' => 'topics', 
     'hide_empty' => 0, 
     'exclude' => $current_tax_ids // exclude the terms 
    ); 

    // get all the terms 
    $all_terms = get_terms($args); 
    // now do whatever you want 

당신이 내 의견을 따르는 경우에 그래서 명확해야한다, 그러나 기본적으로 현재 포스트 용어를 얻을 수 및 배열에 ID를 저장하려면, 다음 단순히 get_terms 할 때 ID를 제외하십시오.