admin管理员组文章数量:1130349
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 badges1 Answer
Reset to default 0You 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
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 badges1 Answer
Reset to default 0You 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
本文标签: To get list of bottom most or deepest or last child for specified parent category
版权声明:本文标题:To get list of bottom most or deepest or last child for specified parent category 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749125498a2319710.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论