I need to get the title of my top-level navigation. I already know the ID of the top-level menu-item but i need to get its title. How can one do that?
I currently have menu like this:
- Level1
- Level2 #1
- Level2 #2
- Level2 #3
If im on any of the level 2 pages i have the Level 1 menu-item ID. I need to get the title in the current theme-location instance.
<?php if(getTopSelectedMenu('primary')):
$topParent = intval(getTopSelectedMenu('primary'));
$topParentTitle = "";
?>
<div class="sidebar-menu-headline"><?=$topParentTitle?><i class="fa fa-arrow-down" aria-hidden="true"></i></div>
<?php
$args = array(
'menu' => '',
'menu_class' => 'sidebar-menu',
'container' => 'ul',
'theme_location' => 'primary',
'level' => 2,
'child_of' => $topParent,
'echo' => FALSE,
'fallback_cb' => '__return_false'
);
$submenu = wp_nav_menu( $args );
if ( ! empty ($submenu) )echo $submenu;
?>