Here are my costume functions that I wrote for the menu and submenu in my wordpress theme, but after I tested it the submenu disappeared when I clicked on a submenu, because wordpress doesn’t separate categories from subcategories, so the parameter for them is “cat”, which means that when I click on a submenu then the function that creates the submenu checks if cat=id in the url has child categories but it doesn’t because it is a child category, I am new into wordpress and I don’t know how to deal with this:
function costume_menu() {
$categories = get_categories('hide_empty=0&style=none&parent=0');
foreach ($categories as $category) {
(is_category($category->term_id)) ? $active = 'class="active_menu"' : $active = '';
$nav = '<li>';
$nav .= '<a '.$active.'href="'.get_category_link($category->term_id).'">'.strtoupper($category->cat_name).'</a>';
$nav .= '</li>';
echo $nav;
}
}
function costume_submenu($cat) {
$categories = get_categories("child_of=$cat&hide_empty=0");
foreach ($categories as $category) {
(is_category($category->term_id)) ? $active = 'class="active_menu"' : $active = '';
$nav = '<li>';
$nav .= '<a '.$active.'href="'.get_category_link($category->term_id).'">'.strtoupper($category->cat_name).'</a>';
$nav .= '</li>';
echo $nav;
}
}
What would you like your menu to look like?
If this be the end result then what we need is to
that menu should show if its child or children’s children have been
selected.
More exact detail to follow if you wish.