Created
April 17, 2012 16:29
-
-
Save markoheijnen/2407319 to your computer and use it in GitHub Desktop.
Get WordPress menu title by theme location
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_menu_title( $theme_location, $default_name = 'menu' ) { | |
if ( $theme_location && ( $locations = get_nav_menu_locations() ) && isset( $locations[ $theme_location ] ) ) { | |
$menu = wp_get_nav_menu_object( $locations[ $theme_location ] ); | |
if( $menu && $menu->name ) { | |
return $menu->name; | |
} | |
} | |
return $default_name; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Greate gist, thanks a lot!!!