Last active
February 12, 2016 02:30
-
-
Save rabidgadfly/148d7ad1ccaf52137a56 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <?php | |
| // | |
| // Source: http://snippets.khromov.se/dynamically-populating-advanced-custom-fields-values/ | |
| // | |
| //Populate the Select field field_5587fccf24f38 with dynamic values | |
| add_filter('acf/load_field/key=field_5587fccf24f38', function($field) { | |
| //These can be dynamically generated using any PHP code | |
| $field['choices']['one'] = 'Choice one'; | |
| $field['choices']['two'] = 'Choice two'; | |
| return $field; | |
| }); | |
| ?> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example of populating fields dynamically in ACF using the acf/load_field hook.