admin管理员组文章数量:1287650
there. I've tried tons of solutions I've found in this forum before asking this. It's kind of hard for me to understand the php sintaxe. I have no idea how to do this and i've been stuck for days trying hundreds of codes. Can someone help me?
I have the following categories:
- Animal
-- Dog
--- frenchie-1
--- frenchie-2
--- frenchie-3
Animal > Dog > frenchie-3
I need to get the slug from "frenchie-3", that is the last one in this situation. Maybe in the future will be a frenchie-4 and I would need to retrieve this "new last" category of that child category. I will always need the last one.
Thanks a lot for your attention.
there. I've tried tons of solutions I've found in this forum before asking this. It's kind of hard for me to understand the php sintaxe. I have no idea how to do this and i've been stuck for days trying hundreds of codes. Can someone help me?
I have the following categories:
- Animal
-- Dog
--- frenchie-1
--- frenchie-2
--- frenchie-3
Animal > Dog > frenchie-3
I need to get the slug from "frenchie-3", that is the last one in this situation. Maybe in the future will be a frenchie-4 and I would need to retrieve this "new last" category of that child category. I will always need the last one.
Thanks a lot for your attention.
Share Improve this question asked Nov 6, 2021 at 4:33 JayJay 111 bronze badge1 Answer
Reset to default 1I've finally figured out the result I wanted with get_categories:
get_categories( array(
'orderby' => 'name', // get the name of category
'order' => 'DESC', // descending order
'parent' => 14, // category_id
'number' => 1 // only one category (the last one, because DESC)
));
本文标签: phpHow to get the last category name of a child category
版权声明:本文标题:php - How to get the last category name of a child category? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741231728a2362232.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论