Created
October 27, 2019 08:49
-
-
Save mishterk/5a89db7d4781d3d2e0a1f04bc9ab0858 to your computer and use it in GitHub Desktop.
Load an ACF field's options dynamically via PHP. For more info see https://philkurth.com.au/tips/load-an-acf-field's-options-dynamically-via-php/
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
<?php | |
add_filter( 'acf/load_field/name=countries', function ( $field ) { | |
$field['choices'] = [ | |
'au' => 'Australia', | |
'nz' => 'New Zealand', | |
'gb' => 'United Kingdom', | |
'us' => 'United States', | |
// … | |
]; | |
return $field; | |
} ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment