I want to list all the last deepest / bottom most childs of a specified parent category in a page. the structure is

  • Parent A

    • child 1

      • grand child 1
    • child 2

      • grand child 2

        • great grand child 1
    • child 3

      • grand child 3

... I need to list all the last childs of specified parent, say for above example i need list for ParentA and the results should be like this

  • grand child 1
  • great grand child 1
  • grand child 3

is there any code to display in a page. I'm new to wp and PHP. Thanks in advance

1 Answer 1


You can use wp_list_categories to achieve that:

        wp_list_categories( array(
            'child_of' => <PARENT_ID>, // show only children of PARENT_ID
            'childless' => true, // show only categories without children
            'hide_empty' => true, // should empty categories be hidden
        ) );

You can find full list of available params here: https://developer.wordpress.org/reference/classes/wp_term_query/__construct/#parameters

  • thanks for reply. but using this childless=> true it shows no category. for childless => false it shows all childs and grand childs . I use shortcode of 'php snnipets' plugin to insert php in my post. will that be problem or where i have to insert the above code in wp site. Dec 8, 2018 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.