php 获取类别列表,排除未分类

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php 获取类别列表,排除未分类相关的知识,希望对你有一定的参考价值。

https://wordpress.stackexchange.com/questions/198981/how-can-i-list-all-the-categories-under-a-custom-post-type-taxonomy

<?php

$terms = get_terms( 'my_taxonomy' );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
 echo '<ul>';
 foreach ( $terms as $term ) {
   if ( $term->name == "Uncategorized" ) continue;
   echo '<li>' . $term->name . '</li>';

 }
 echo '</ul>';
}

以上是关于php 获取类别列表,排除未分类的主要内容,如果未能解决你的问题,请参考以下文章