Created
May 9, 2018 11:40
-
-
Save giventofly/d9ac765f16a9ad93a160c21123f45349 to your computer and use it in GitHub Desktop.
ACF load values to select field from another field
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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