I’ve just solved this issue thanks to the Avanced WordPress group in Facebook (https://www.facebook.com/groups/advancedwp/). It was actually a mistake I had made: I had a query before the custom fields and it had to be reset. This is the working snippet:
<?php
// WP_Query arguments
$args = array (
'post_type' => 'post',
'posts_per_page' => '4',
);
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
the_title();
}
} else {
echo 'No posts found';
}
// Restore original Post Data: this line was missing in my original code; adding it solved the issue.
wp_reset_postdata();
?>
<?php if( have_rows('logo_grid_logos') ): ?>
<?php while( have_rows('logo_grid_logos') ): the_row(); ?>
<img src="https://wordpress.stackexchange.com/questions/188440/<?php echo get_sub_field("logo_grid_img'); ?>">
<?php endwhile; ?>
<?php endif; ?>
My original query is a little more complex but this is a working example.
Thanks!