[英]function to show the categories without the subcategories in wordpress with the get_categories() function
我做了这个功能来显示主题的顶部导航:
function costume_menu() {
$categories = get_categories('hide_empty=0&style=none');
foreach ($categories as $category) {
$nav = '<li>';
$nav .= '<a href="'.get_category_link($category->term_id).'">'.strtoupper($category->cat_name).'</a>';
$nav .= '</li>';
echo $nav;
}
}
但是它同时显示了所有类别和子类别,我尝试在wordpress的法典站点上阅读,以仅排除子类别,但我什么都找不到!
这应该工作
$categories = get_categories('hide_empty=0&style=none&parent=0');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.