I’m attempting to create a custom field on my page creation that allows a user to choose which menu to display on the page. Right now I have my custom meta field setup, but can’t figure out how to make a drop down menu of the available menus. Is there a function that I could use and then for loop though?
Thanks!
It is not intuitive but
get_terms
will do it, if I understand what you need.If you look in the
*_term_taxonomy
table you can see why. The menus are stored as a taxonomy namednav_menu
.This won’t get you things like page menus, only the intentionally created menus.
If you prefer a code-based solution, the one from s_ha_dum is perfectly valid.
A out-of-the-box solution based on a plugin without any code editing would be ACF with Nav Menu Field extension.