简体   繁体   English

get_terms()顺序不遵循层次结构

[英]get_terms() order not follow hierarchy

Here is how I get all terms, including children, of a custom hierarchical taxonomy: 这是我如何获取自定义分层分类法的所有术语(包括子代)的方法:

$args = array(
    'taxonomy'      => 'obra_tema',
);

$themes = get_terms($args);

Very simple. 很简单。 But instead the list look like that: 但是,列表看起来像这样:

  1. Books 图书
  2. Cars 汽车
  3. Others 其他
  4. DVD (child of Others) DVD(他人之子)

The function return 函数返回

  1. Books 图书
  2. Cars 汽车
  3. DVD (child of Others) DVD(他人之子)
  4. Others 其他

How can I show terms in the same order of dashboard? 如何以相同的仪表板顺序显示术语?

Have not tried this, but it should be something like this 还没有尝试过,但是应该是这样的

$args = array(
    'taxonomy' => 'obra_tema',
    'orderby' => 'id',
    'order' => 'DESC',
);

$themes = get_terms($args);

You might have to adjust the order field or the order by direction. 您可能必须调整订单字段或按方向订购。

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

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