最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to list all subcategories from all categories but not from a certain category

programmeradmin2浏览0评论

I know how to list all subcategories from a certain category, but don't know how to list all subcategories from all categories.

For example, here is category:

Category 1
    -Child Category1
    -Child Category2
Category 2
    -Child Category3
    -Child Category4
Category 3
    -Child Category5
    -Child Category6

The list i want is :

-Child Category1
-Child Category2
-Child Category3
-Child Category4
-Child Category5
-Child Category6

This is code i have now

<?php wp_list_categories( array(
    'orderby'=> 'id',
    'order' => 'DESC',
    'show_count' => false,
    'use_desc_for_title' => false,
     'title_li' => '',
) ); ?>

I know how to list all subcategories from a certain category, but don't know how to list all subcategories from all categories.

For example, here is category:

Category 1
    -Child Category1
    -Child Category2
Category 2
    -Child Category3
    -Child Category4
Category 3
    -Child Category5
    -Child Category6

The list i want is :

-Child Category1
-Child Category2
-Child Category3
-Child Category4
-Child Category5
-Child Category6

This is code i have now

<?php wp_list_categories( array(
    'orderby'=> 'id',
    'order' => 'DESC',
    'show_count' => false,
    'use_desc_for_title' => false,
     'title_li' => '',
) ); ?>
Share Improve this question asked May 18, 2020 at 12:48 user18787user18787 33 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

Well, according to official documentation, you should pass depth argument inside your function.

As it's written here

Try this:

  <?php wp_list_categories( array(
    'orderby'=> 'id',
    'order' => 'DESC',
    'show_count' => false,
    'use_desc_for_title' => false,
    'title_li' => '',
    'depth; => 1
   ) ); ?>
发布评论

评论列表(0)

  1. 暂无评论