1

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!

2

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.