2017-10-04 8 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

あなたはこのような何か行うことができます:あなたは私のコメントに従うならば、それは明確にする必要がありますが、基本的には現在のポスト用語を取得し、配列内のIDを格納したいので

// 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 

get_termsを実行したときにidsを除外するだけです。

関連する問題