Last active
August 8, 2024 19:41
-
-
Save stnc/d9ae6fd86e7ec901236451b2ee59d171 to your computer and use it in GitHub Desktop.
How to get all registered menus in wordress #menu #WordPress
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
<?php $menus = get_registered_nav_menus(); | |
foreach ( $menus as $location => $description ) { | |
echo $location . ': ' . $description . '<br />'; | |
} |
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
<?php | |
$menus = get_terms( 'nav_menu' ); | |
$menus = array_combine( wp_list_pluck( $menus, 'term_id' ), wp_list_pluck( $menus, 'name' ) ); | |
echo "<pre>"; | |
print_r( $menus ); | |
$menus = get_terms( 'nav_menu' ); | |
$menus = array_combine( wp_list_pluck( $menus, 'term_id' ), wp_list_pluck( $menus, 'name' ) ); | |
foreach ( $menus as $location => $description ) { | |
echo $location . ': ' . $description . '<br />'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment