Acf Pro repeater field returns null

I’m having a problem with the repeater field in Acf Pro. Basically, it works fine in the admin (it saves the data), but nothing shows up in the front. It’s driving me mad because I’m using the exact same snippet in another website, same WP version, same ACF version, and it’s working, but with the website I’m currently developing I’m having this problem both locally and in production.

The name of the repeater field is logo_grid
It has an image field inside (URL type) named logo_grid_img

This is my code:

<?php if( have_rows('logo_grid_logos') ): ?>
    <?php while( have_rows('logo_grid_logos') ): the_row(); ?>
        <img src="<?php echo get_sub_field('logo_grid_img'); ?>">
    <?php endwhile; ?>
<?php endif; ?>

I tried var_dump and it just returns null.

<?php $my_var_dump =  get_field('logo_grid_logos'); ?>
<?php var_dump($my_var_dump); ?>

I’m quite desperate. Does anyone have any clues?

Solutions Collecting From Web of "Acf Pro repeater field returns null"

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="<?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!