WordPress 建网站时需要在侧边栏调用当前栏目的子分类子目录,而且在点击子目录时还会侧边栏显示这些子目录的分类,其实就是我们说的分类文章列表页,荒岛本次带来 WordPress 不同分类调用当前子分类的教程,只要将下面的代码添加到主题的「functions.php」文件即可。
// 荒岛一座藏有宝藏的小岛 function get_category_id($cat) { $this_category = get_category($cat); while($this_category->category_parent) { $this_category = get_category($this_category->category_parent); } return $this_category->term_id; }宝藏内容来自荒岛-https://x-imagine.com/wordpress-calls-the-current-subcategory.html宝藏内容来自荒岛-https://x-imagine.com/wordpress-calls-the-current-subcategory.html
请按 Ctrl+D 收藏荒岛分享给好友 如您发现本文件已经失效无法下载请联系站长修正
荒岛公众号
扫一扫关注

HDsoft27
公众号ID已复制,前往微信关注...
荒岛小程序
扫一扫关注

ximagine
哔哩姬ID已复制,前往B站关注...