$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>To get list of bottom most or deepest or last child for specified parent category|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

To get list of bottom most or deepest or last child for specified parent category

matteradmin10PV0评论

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

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

Share Improve this question asked Dec 5, 2018 at 20:31 Selva KumzzSelva Kumzz 113 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can use wp_list_categories to achieve that:

<ul>
    <?php
        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
        ) );
    ?> 
</ul>

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

Post a comment

comment list (0)

  1. No comments so far