with print_r() we can see what type of info we are getting, an array this case…
<?php
$relatedPrograms = get_field('related_programs');
print_r($relatedPrograms);
?>
<?php
$relatedPrograms = get_field('related_programs');
//print_r($relatedPrograms);
foreach($relatedPrograms as $program){
echo get_the_title($program);
}
?>
<?php
$relatedPrograms = get_field('related_programs');
//print_r($relatedPrograms);
//Check if there are related programs cause if not will trigger error
//If $relatedPrograms TRUE
if ($relatedPrograms){
echo '<hr class="section-break">';
echo '<h2 class="headline headline--medium">Related Program(s)</h2>';
echo '<ul class="link-list min-list">';
foreach($relatedPrograms as $program){ ?>
<li><a href="<?php get_the_permalink($program); ?>"><?php echo get_the_title($program); ?></a></li>
<?php }
echo '</ul>';
}//end if statement $relatedPrograms
?>