我在检索正在查看的自定义帖子的当前类别的名称(或ID)(在循环中)时遇到了极大的困难。
当前类别名称为“school”,是名为“category\\u news”的自定义类别的子类别
我正在尝试以下操作,但返回为空。
$terms = get_the_terms( $post->ID , \'category_news\' );
if ( $terms != null ){
foreach( $terms as $term ) {
print $term->slug ;
unset($term);
}
}