通过自定义帖子类型获取get_terms
我有两个自定义帖子类型“国家”和“城市”,以及一个共享的分类法“标志”。 如果我使用: <?php $flags = get_terms('flag', 'orderby=name&hide_empty=0'); 我得到了分类法中所有术语的列表,但是我想将列表限制为“国家”这一职位类型。 我该怎么做? 使用新的解决方案 <?php $flags = wpse57444_get_terms('flags',array('parent' => 0,'hide_empty' => 1,'post_types' =>array('country'))); foreach ($flags as $flag) { $childTerms = wpse57444_get_terms('flags',array('parent' => $flag->term_id,'hide_empty' => 1,'post_types' =>array('country'))); foreach ($childTerms as $childTerm) { echo $childTerm->name.'<br />'; } } ?> 我无法回显$ childTerm-> name。为什么?