Last active
March 19, 2019 13:31
-
-
Save kisildev/88ababceff72077a85cd285f0bff5938 to your computer and use it in GitHub Desktop.
ACF Choises
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
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