Advanced Custom Fields Repeater Loop with Fallback
$parent = 'parent_field';
$field = 'sub_field';
$post_type = 'post';
if( function_exists( 'have_rows' ) ) :
if( have_rows( $parent, 'option' ) ):
while ( have_rows( $parent, 'option' ) ) :
the_row();
// Stuff
endwhile;
endif;
else :
$rows = $wpdb->get_results( $wpdb->prepare( " SELECT *
FROM {$wpdb->prefix}posts
INNER JOIN {$wpdb->prefix}postmeta
ON ({$wpdb->prefix}posts.ID = {$wpdb->prefix}postmeta.post_id)
WHERE {$wpdb->prefix}posts.ID = $post->ID
AND {$wpdb->prefix}posts.post_type = $post_type
AND {$wpdb->prefix}postmeta.meta_key
LIKE %s", $parent . '_%_' . $field ) );
if( $rows ) :
foreach( $rows as $row ) :
preg_match( '_([0-9]+)_', $row->meta_key, $matches );
$meta_key = $parent . '_' . $matches[0] . '_' . $field;
$post_meta = get_post_meta( $row->post_id, $meta_key, true );
// Stuff
echo $post_meta; // The Field
endforeach;
endif;
endif;