Support

Account

Home Forums Front-end Issues Accessing all Advanced Custom Field checkbox values Reply To: Accessing all Advanced Custom Field checkbox values

  • You can use like this:

    //Get all items from fieldname
    $fieldname = get_field('fieldname', $current_user);
    $id = get_the_ID();
    
    $field = get_field_objects($current_user);
    
    $field_name = $field["field_name"]["name"];
    
    if( $field ){
      foreach ( $field["fieldname"]['choices'] as $key => $value) {
    							if ( in_array( $key, $newsletter  ) ) {
    								$checked = 'checked';
    							}else{
    								$checked = '';
    							}
    							echo '<p class="field"><input type="checkbox" '.$checked.' name="'.$field_name.'" value="'.$key.'">'.$value.'</p>';
    						}
    					}