Home › Forums › Backend Issues (wp-admin) › Dynamic choice select on post object selects › Reply To: Dynamic choice select on post object selects
Ah, the late timing of the prepare_field filter seems to make this possible via the $field[‘value’] key
function preselect_an_option( $field ) {
if (isset($_GET['book_author'])){ // or however you get the value dynamically
$field['value'] = $_GET['book_author']; // this is where it gets selected!
}
return $field;
}
add_filter('acf/prepare_field/name=book_author', 'preselect_an_option');
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.