Created
March 13, 2018 22:22
-
-
Save nickdavis/25d4a733b7c2754ca1e34db31a735bb0 to your computer and use it in GitHub Desktop.
Get a WordPress menu from a specific menu 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
<?php | |
/** | |
* Returns the menu object associated with a particular menu location. | |
* | |
* You could then get the slug of the menu, for example, via | |
* $menu_object->slug (or whatever variable you saved the menu object as). | |
* | |
* @param string $location_slug | |
* | |
* @return object | |
*/ | |
function get_menu_from_location( $location_slug ) { | |
return get_term( get_nav_menu_locations()[$location_slug], 'nav_menu' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment