-
-
Save SteveJonesDev/c67e673b5f0828b4b738d5f4581c0005 to your computer and use it in GitHub Desktop.
Get WordPress menu title by theme location
This file contains hidden or 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