Home › Forums › General Issues › Define a default taxonomy (radio button) › Reply To: Define a default taxonomy (radio button)
You can try to add a filter that will select a default value if none is selected already. Perhaps something like this:
add_filter('acf/load_value/name=your_taxonomy_field_name', 'set_default_taxonomy_selection', 10, 3);
function set_default_taxonomy_selection($value, $post_id, $field) {
// Check if the field has a value
if (!$value && empty($_GET['post'])) {
// Set the default term ID here
$default_term_id = 7;
$value = $default_term_id;
}
return $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.