Created
February 10, 2015 15:39
-
-
Save Sjouw/c5d3edf6dc2982847999 to your computer and use it in GitHub Desktop.
WordPress - Show dynamic menu title above menu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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