<?php $posts = get_field('acf_relationship_field'); if( $posts ): ?> <div class="wp-block <?php echo $align_class; ?>"> <?php foreach( $posts as $post): // variable must be called $post (IMPORTANT) ?> <?php setup_postdata($post); ?> <?php if ($post->post_status == 'publish') { ?> <?php the_content(); ?> <?php } else { ?> <p>No posts available...</p> <?php } ?> <?php endforeach; ?> </div> <?php wp_reset_postdata(); // IMPORTANT - reset the $post object so the rest of the page works correctly ?> <?php endif; ?>