Support

Account

Home Forums Backend Issues (wp-admin) Dropdown value saved but not loaded back Reply To: Dropdown value saved but not loaded back

  • Hi James,

    Sorry for the delay, I had to work on other projects.
    I’ve tried using acf/load_field, sadly without luck.
    I think I also need to use acf/load_value.

    Here’s what I’ve done so far:

    $imageSizeSelect = 'field_5831de3000470';
    global $databaseValue;
    
    function my_acf_load_value($value, $post_id, $field){
    	$databaseValue = $value;
    }
    add_filter('acf/load_value/key=' . $imageSizeSelect, 'my_acf_load_value', 9, 3);
    
    function my_acf_load_field($field){
    	$field['choices'][$databaseValue] = $databaseValue;
    	return $field;
    }
    add_filter('acf/load_field/key=' . $imageSizeSelect, 'my_acf_load_field', 10, 1);

    I’m clearly missing something (which by chance will seems obvious to you).
    First thing I’ve noticed, it that load_field is always run before load_value, which implies I’m getting an empty value.