Checkboxes Count = Number Field
-
add_action('acf/save_post', 'count_titles'); function count_titles($post_id) { $post_id = "teams"; // ACF teams field values. $sixteenRegion = get_field('16th_region_title_year_won', 'teams'); // Calculate total pets. $calcSixteen = count($sixteenRegion); // Update ACF field for total_pets. update_field('total_16th_region_titles', $calcSixteen, $post_id); } add_filter('acf/format_value/type=number', 'format_numbers'); function format_numbers($value, $post_id, $field) { $value = number_format($value); return $value; }
I know this code is probably very wrong. I’ve tried piecing it together from other researching common threads but I can’t seem to get it to work the way I want it.
I am trying to autopopulate the number field based on how many checkboxes are checked in another field. So for example, if the checkbox field has 5 of the 16 checkboxes checked. Then “5” should be populated in the number field above. I keep getting an error and it’s probably from just a dumb syntax error or just plain wrong code. IAny help would be great!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Checkboxes Count = Number Field’ is closed to new replies.