Support

Account

Home Forums Front-end Issues Hardcode taxonomy values in frontend form Reply To: Hardcode taxonomy values in frontend form

  • https://support.advancedcustomfields.com/forums/topic/default-value-for-the-taxonomy-field-type/, the second solution I gave works in the admin. You’ll need to play with this since it’s a front end form and depending on what type of field it is, for checkboxes and miulti select fields you want to return an array but for single select and radio you’ll want to return just a single term ID.

    I’m guessing here about what the $post_id value will be

    
    add_filter('acf/load_value/name=taxonomy_field_name', 'default_term_for_taxonomy_field_name', 10, 3);
    function default_term_for_taxonomy_field_name($value, $post_id, $field) {
      if ($value === false && get_post_status($post_id) == 'new_post') {
        $value = array(3);
      }
      return $value;
    }