I am having a hard time trying to get the name of the active menu and, apparently, I cannot find any solutions to this issue. Basically, I have several menus that follow this pattern:
- Menu Item 1
- Menu Item 2
- Menu Item n
I want to display the menu name of the current page item, but I cannot find any way of doing it. I have tried using get_nav_menu_locations() in conjunction with get_term():
$theme_locations = get_nav_menu_locations(); $menu_obj = get_term($theme_locations["menu_1"], 'nav_menu'); $menu_name = $menu_obj->name;
However, I need to get the location of the current menu dynamically and after searching for answers/solutions and not finding anything concrete, I just assume that there may be at least a database relationship between the current menu item and the menu object to which is assigned; from where I would eventually get the menu location/term ID.
Any ideas, please? I have already spent about 2 hours on this.
Thank you in advance!
PS: I want to output the active menu title without the use of JS