WordPress的:如何从一个类别获得第一级的儿童? [英] Wordpress: how to get first level of children from a category?

查看:152
本文介绍了WordPress的:如何从一个类别获得第一级的儿童?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  Cat 1 $ b $我想知道是否有一个函数只返回子类别的子类。 b小1.1 
小1.2
小1.2.1
猫2
小2.1

这里我只想要:Sub-1.1,Sub-1.2和Sub-2.1



原因使用带有child_of参数的get_categories带来我所有的孩子,直到最后一个节点:$ b​​
$ b

  get_categories('orderby = id& show_count = 0& title_li =& use_desc_for_title = 1& amp ; child_of = $ this_category-> CAT_ID); 

谢谢

解决方案请尝试

  wp_list_categories(array('depth'=> 2)); 


I want to know if has a function that return only the first level of subcategories children.

Cat 1
   Sub-1.1
   Sub-1.2
       Sub-1.2.1
Cat 2
   Sub-2.1

Here I want only: Sub-1.1, Sub-1.2 and Sub-2.1

Cause using get_categories with child_of parameter brings me all children until the last node:

get_categories('orderby=id&show_count=0&title_li=&use_desc_for_title=1&child_of='.$this_category->cat_ID);

Thanks

解决方案

Please try

wp_list_categories(array('depth' => 2));

这篇关于WordPress的:如何从一个类别获得第一级的儿童?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆