显示除当前页面之外的所有条款

Show all terms excluding the current page

下面列出了所有的条款,我可以得到帮助来修改它以显示除 active/current 页面之外的所有条款吗?谢谢。

$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>';
  }
}

你可以这样做:

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

所以如果你遵循我的评论,它应该很清楚,但基本上你想获得当前的 post 条款并将 id 存储在数组中,然后在你执行 [=11= 时简单地排除 ids ].