 <?php if(get_sub_field('white_bg')) { 
$bg_class = 'white';
} else {
	$bg_class = '';
}
?> 
<div id="related-pages" class="<?php echo $bg_class; ?>">
<div class="container">
	<div class="section">
<?php if(get_sub_field('sec_title')) { ?>  
            <div class="title"><?php the_sub_field ('sec_title'); ?></div>
            <?php } ?>
	

<?php if(get_sub_field('sec_text')) { ?>  
            <div class="entry"><?php the_sub_field ('sec_text'); ?></div>
            <?php } ?>
	
<?php  

$posts = get_sub_field('rp_pages');
if (!empty ($posts)) {?>

<div class="rel-list">
	<div class="row justify-content-center">
    <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?>
        <?php setup_postdata($post); ?>
     
     <div class="col-lg-3"><?php  get_template_part('parts/articlesloop'); ?></div><!--col-->
                
        
    <?php endforeach; ?>

    <?php wp_reset_postdata(); ?>

 </div><!--row-->  
</div><!--related-boxes-->
<?php } ?>

	</div><!--section-->
</div><!--container-->
</div><!--related-->