Skip to content

Instantly share code, notes, and snippets.

@Sjouw
Created February 10, 2015 15:39
Show Gist options
  • Save Sjouw/c5d3edf6dc2982847999 to your computer and use it in GitHub Desktop.
Save Sjouw/c5d3edf6dc2982847999 to your computer and use it in GitHub Desktop.
WordPress - Show dynamic menu title above menu
function get_theme_menu_name( $theme_location ) {
if ( !has_nav_menu( $theme_location ) ) return false;
$menus = get_nav_menu_locations();
$menu_title = wp_get_nav_menu_object( $menus[$theme_location] )->name;
return $menu_title;
}
<h3><?php echo get_theme_menu_name( 'my-menu-name' ); ?></h3>
<?php wp_nav_menu(array(
'theme_location' => 'my-menu-name',
'depth' => 1,
'container' => ''
)); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment