Skip to content

Instantly share code, notes, and snippets.

@kisildev
Last active March 19, 2019 13:31
Show Gist options
  • Save kisildev/88ababceff72077a85cd285f0bff5938 to your computer and use it in GitHub Desktop.
Save kisildev/88ababceff72077a85cd285f0bff5938 to your computer and use it in GitHub Desktop.
ACF Choises
function acf_load_cats_choices( $field ) {
// reset choices
$field['choices'] = array();
// get the textarea value from options page without any formatting
$choices = get_hubspot_data( false, true );
// loop through array and add to field 'choices'
if ( is_array( $choices ) ) {
$field['choices']['0'] = 'All';
foreach ( $choices['topics'] as $key => $choice ) {
$field['choices'][ $key ] = $choice;
}
}
// return the field
return $field;
}
add_filter( 'acf/load_field/key=field_5c8be31281dfa', 'acf_load_cats_choices' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment