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 获取类别列表,排除未分类的主要内容,如果未能解决你的问题,请参考以下文章

在 PHP 和 MySQL 中使用联结表来分类和包含和排除类别

php 排除未分类

Wordpress:使用 post__not_in 排除自定义分类类别

获取分类变量的类别列表(Python Pandas)

php 从默认值获取类别,而不是分类

php 从主类别中获取Magento子类别列表