以下列出了所有条款,我可以帮助修改它,以便显示除活动/当前页面之外的所有条款吗?谢谢。
$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 :(得分:0)
您可以这样做:
isOk
因此,如果您按照我的意见进行操作,则应该很清楚,但基本上您希望获取当前的帖子术语并将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
时简单地排除ID。