how to get all the child category name in a specified category name?

Supposed the specified category name is “product”, which has three layered sub-categories. The structure is like the following:

  • product one
    • product two
      • product three
        • product four

I want to output all the subcategory names in the sidebar.php of my theme. How do I do?

Read More

in my theme index.php i using: <?php include("productHallofHome.php");?>
in productHallofHome.php i using code:

<ul class="productList_h">
<?php wp_list_categories( 'child_of=4&depth=0'); ?>
    </ul>

Related posts

Leave a Reply

1 comment

  1. Please have a look at wp_list_categories, which is all you need. Just choose the arguments to your liking and place the code in your sidebar.

    Suppose, the ID of your ‘product’ category is 666, then the basic code could look like the following:

    <ul>
    <?php wp_list_categories( 'child_of=666&hide_empty=0'); ?>
    </ul>