Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save giventofly/d9ac765f16a9ad93a160c21123f45349 to your computer and use it in GitHub Desktop.
Save giventofly/d9ac765f16a9ad93a160c21123f45349 to your computer and use it in GitHub Desktop.
ACF load values to select field from another field
//check select field from .json
add_filter('acf/load_field/key=field_5af2cece02f00', function( $field ){
// options of the choices to add to select
$field['choices'] = array();
// dynamic data we want to popuplate with
$bundles = get_field('gerir_marcas', 'option' );
//$portfolio = get_field('item_portfolio','option');
//var_dump($bundles);
foreach( $bundles as $bundle ){
// $value = $label
// the bundle_id will be saved to the database
// while the bundle_name is shown to the user
$field['choices'][$bundle['marca']] = $bundle['marca'];
}
// All done!
return $field;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment