A custom field for ACF that allows you to select any WordPress menu.
This plugin will add a new ACF field called "Menu" which can be found under "Relational". This field will allow you to pick from a list of all WordPress menu that have been added from the "Appearance > Menu" setting screen.
It will return a menu id which you can then use with function like wp_nav_menu();
.
Here’s an example:
$menu_id = get_field('main_menu');
$args = array(
'menu' => $menu_id,
'container' => 'ul',
'items_wrap' => '%3$s'
);
wp_nav_menu($args);
This plugin was created because a project we were working on required different menus on different pages. These menus needed to support submenus as well. Rather than recreate a menu editing experience, why not use what WordPress already provides us?
That said, you can build out all of the menus you need from the native menu builder in WordPress and use this plugin to select it on any page you need.
This ACF field type is compatible with:
- ACF 5
- ACF 4
- Copy the
acf-menu-field
folder into yourwp-content/plugins
folder - Activate the Menu plugin via the plugins admin page
- Create a new field via ACF and select the Menu type
- Read the description above for usage instructions