Create a select drop down of available menus

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!

Related posts

2 comments

  1. It is not intuitive but get_terms will do it, if I understand what you need.

    var_dump(get_terms( 'nav_menu'));
    

    If you look in the *_term_taxonomy table you can see why. The menus are stored as a taxonomy named nav_menu.

    This won’t get you things like page menus, only the intentionally created menus.

  2. 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.

Comments are closed.