Skip to content

Instantly share code, notes, and snippets.

@markoheijnen
Created April 17, 2012 16:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save markoheijnen/2407319 to your computer and use it in GitHub Desktop.
Save markoheijnen/2407319 to your computer and use it in GitHub Desktop.
Get WordPress menu title by theme location
<?
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;
}
?>
@olehlavryk
Copy link

Greate gist, thanks a lot!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment