Reputation: 415
I made this function to show the top navigation for my theme:
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;
}
}
but it shows all the categories and subcategories together, I tried to read in the codex site of wordpress to exclude only subcategories but I couldnt find anything!
Upvotes: 1
Views: 2065
Reputation: 222060
This should work
$categories = get_categories('hide_empty=0&style=none&parent=0');
Upvotes: 5