Skip to content

Instantly share code, notes, and snippets.

@mishterk
Created October 27, 2019 08:49
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 mishterk/5a89db7d4781d3d2e0a1f04bc9ab0858 to your computer and use it in GitHub Desktop.
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/
<?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