Home › Forums › ACF PRO › udpating Select2 initial choices to match database field › Reply To: udpating Select2 initial choices to match database field
Asking the question in public is always the fastest way to find the answer yourself. 😉 This needs some refinement, but setting the $field[‘default_value’] in a acf/load_field hooked function that runs after most other things is working:
add_filter('acf/load_field/type=taxonomy', function( $field ) {
$screen = get_current_screen();
if ( $screen->base = 'term' && $screen->parent_base == 'edit' ) {
$term_id = (int) $_REQUEST['tag_ID'];
$field['default_value'] = get_term_meta( $term_id, $field['name'] );
}
return $field;
}, 99, 1);
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.