Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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!

share|improve this question
add comment

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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