Skip to content

Instantly share code, notes, and snippets.

@alessandrotesoro
Created March 3, 2014 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alessandrotesoro/9333843 to your computer and use it in GitHub Desktop.
Save alessandrotesoro/9333843 to your computer and use it in GitHub Desktop.
Filter Advanced Custom Fields Plugin Select Field with all created menu, modify "field_name" with the name of the select field.
function tdp_filter_field_with_menus( $field ) {
// reset choices
$field['choices'] = array();
$menus = get_terms('nav_menu');
foreach($menus as $menu){
$field['choices'][ $menu->slug ] = $menu->name;
}
// Important: return the field
return $field;
}
add_filter('acf/load_field/name=field_name', 'tdp_filter_field_with_menus');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment