问题
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
回答1:
Please try
wp_list_categories(array('depth' => 2));
来源:https://stackoverflow.com/questions/3410695/wordpress-how-to-get-first-level-of-children-from-a-category