繁体   English   中英

从没有帖子的自定义分类中获取条款

[英]Get the terms from a custom taxonomy without posts

我要问的是,是否有内置函数获取以下mysql查询的结果? get_terms()似乎仅获得分配给例如帖子的术语,而不是整个列表。

select 
    name
from
    wordpress.wp_terms
where
    term_id in (select 
            term_id
        FROM
            wordpress.wp_term_taxonomy
        where
            taxonomy = 'custome_taxonomy')

我认为您对get_terms有误解,也不知道get_terms参数的目的

默认情况下,所有没有帖子的术语都是隐藏的,这是参数

'hide_empty'    => true, 

要检索没有帖子的术语,您需要将false传递给hide_empty参数,就像这样

$terms = get_terms( 'hide_empty=false' );

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM