name = 'menu-field'; // variable name (no spaces / special characters / etc) $this->title = __("WordPress Menu",'acf'); // field label (Displayed in edit screens) } function create_options($key, $field){ // defaults $field['multiple'] = isset($field['multiple']) ? $field['multiple'] : '0'; $field['allow_null'] = isset($field['allow_null']) ? $field['allow_null'] : '0'; $menus = get_terms('nav_menu'); ksort($menus); $choices = array(); foreach($menus as $m){ $choices[$m->slug] = $m->name; } ?>

Select the menu to display.

parent->create_field(array( 'type' => 'select', 'name' => "fields[{$key}][wp_menu]", 'value' => $field['wp_menu'], 'choices' => $choices, )); ?> parent->create_field(array( 'type' => 'radio', 'name' => 'fields['.$key.'][allow_null]', 'value' => $field['allow_null'], 'choices' => array( '1' => __("Yes",'acf'), '0' => __("No",'acf'), ), 'layout' => 'horizontal', )); ?> parent->create_field(array( 'type' => 'radio', 'name' => 'fields['.$key.'][multiple]', 'value' => $field['multiple'], 'choices' => array( '1' => __("Yes",'acf'), '0' => __("No",'acf'), ), 'layout' => 'horizontal', )); ?> '0', 'allow_null' => '0', 'optgroup' => false, ); $field = array_merge($defaults, $field); // multiple select $multiple = ''; if($field['multiple'] == '1'){ // create a hidden field to allow for no selections echo ''; $multiple = ' multiple="multiple" size="5" '; $field['name'] .= '[]'; } echo ''; } function admin_head(){ } function admin_print_scripts(){ } function admin_print_styles(){ } function update_value($post_id, $field, $value){ parent::update_value($post_id, $field, $value); } function get_value($post_id, $field){ $value = parent::get_value($post_id, $field); return $value; } function get_value_for_api($post_id, $field){ $value = parent::get_value($post_id, $field); if($value == 'null'){ $value = false; } return $value; } } endif; //end class check if(!class_exists('ACF_Menu_Field_Helper')) : class ACF_Menu_Field_Helper { private static $instance; public static function singleton() { if( !isset( self::$instance ) ) { $class = __CLASS__; self::$instance = new $class(); } return self::$instance; } private function __clone() { } private function __construct() { add_action( 'init', array( &$this, 'register_field' ), 5, 0 ); } public function register_field() { if( function_exists( 'register_field' ) ) { register_field( 'ACF_Menu_Field', __FILE__ ); } } } endif; //end class check ACF_Menu_Field_Helper::singleton();