下面的代码将打印用户组的两倍。提前谢谢。
<?php
$terms = array();
$terms_tags = get_the_terms( $current_user->ID, array( 'user-group' ) );
foreach ( $terms_tags as $term_tag ) {
$terms[$term_tag->slug] = $term_tag->name;
echo $term_tag->slug. ' ';
}
?>发布于 2016-09-07 07:07:16
WordPress文档表示get_the_terms()的第二个参数应该是字符串,而不是数组。你能检查一下这个吗?
试着这样做:
<?php
$terms = array();
$terms_tags = get_the_terms( $current_user->ID, 'user-group' );
foreach ( $terms_tags as $term_tag ) {
$terms[$term_tag->slug] = $term_tag->name;
echo $term_tag->slug. ' ';
}
?>到目前为止,这是我在代码中看到的唯一“问题”。
https://stackoverflow.com/questions/39362540
复制相似问题