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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.