Home › Forums › Backend Issues (wp-admin) › Dropdown value saved but not loaded back › Reply To: Dropdown value saved but not loaded back
Ok James,
I think I made it, but doing my own database request:
if (is_admin()){
$fieldKey = 'field_5831de3000470'; // image_reference
function my_acf_load_field($field){
global $post;
global $wpdb;
$query = "SELECT * FROM 'myDatabaseName'.'wp_postmeta' WHERE 'meta_key' LIKE 'taz_shortcodes_%_image_size_%_image_reference' AND 'post_id' = $post->ID";
$rows = $wpdb->get_results($query);
$field['choices'] = array();
foreach ($rows as $row) {
$field['choices'][$row->meta_value] = $row->meta_value;
}
return $field;
}
add_filter('acf/load_field/key=' . $fieldKey, 'my_acf_load_field', 10, 1);
}
Let me know what you’d have done differently.
Thanks in advance.
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.