I have no idea why I'm finding this so hard. I've gone through many similar posts here, but none are working.
I am building a menu outside of the loop on my index page - it a standard posts page, not a static page set as home. Basically, I want the current page's menu title (ie: Home) to be echoed onto the page. I will put the same code on single/page/archive/etc. Then I'm using wp_nav_menu to echo out the menu beneath it, like so:
<?php wp_nav_menu( array( 'theme_location' => 'secondary', 'container' => 'div', 'container_class' => 'submenu-container sub-menu clearfix', 'menu_class' => 'ipf-sectionmenu' ) ); ?>
So reasonably straightforward.... except for just echoing out the menu title. Temporarily, I'm just echoing out the first item in the menu, which is almost always Home, so that works. Like so:
<?php $top = wp_get_nav_menu_items('Main'); $name = $top->post_title; ?> <h3 id="left-subheader-mobile" class="purple-header"><?php echo $name; ?></h3>
What am I missing?