Wordpress: how to get first level of children from a category?

一个人想着一个人 提交于 2019-12-11 07:14:02

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!