I creater a field that’s a repeater, the fields within the repeater are:
experience_start_year
experience_end_year
experience_present
I am trying to get the value from experience_present
, which is “Present”. I’m then trying to write a conditional statement to say that if “Present” is selected, then output x, if not, output y.
$start_year = get_sub_field('experience_start_year');
$end_year = get_sub_field('experience_end_year');
$present = get_sub_field_object('experience_present');
if( $start_year ) :
$html_out .= '<div class="duration-block">';
if( $present && in_array('present', $present) ) :
$html_out .= '<h5>' . $start_year . ' - ' . $present['present'] . '</h5>';
else :
$html_out .= '<h5>' . $start_year . ' - ' . $end_year . '</h5>';
endif;
$html_out .= '</div>';
endif;
This currently doesn’t output neither “Present” or $end_year
.
What kind of field is experience_present? A checkbox or a true/false field? Please provide more information on this field.