Wordpress的高级自定义字段

I'm using the advanced custom field plugin on a Wordpress site. I'm using the Repeater Field Type to be able to attach more than one file.

My Repeater Field Type is called: electronics

with the sub fields name: electronics_files

Here is what I have so far:

<?php

// check if the repeater field has rows of data
if( have_rows('electronics ') ):

    // loop through the rows of data
    while ( have_rows('electronics ') ) : the_row();

        // display a sub field value
        the_sub_field('electronics_files');

    endwhile;

else :

    // no rows found

endif;

?>

I have the return value for electronics_files as a File URL so I can wrap it inside of an a tag to download.

Right now it returns all the file urls as one long string. How would I do it so it first checks to see if I have datasheet then grabs the first one wraps it around a a tag then loops until there are no more electronics_files.

I have something like this maybe?

if( $file ) {

    $url = wp_get_attachment_url( $file );

    ?><a href="<?php echo $url; ?>" >Download File</a><?php

}

Basically I just want it to display the file I attached as links that can be downloaded.

It sounds like to just need to change this...

the_sub_field('electronics_files');

...to this:

echo '<a href="' . get_sub_field('electronics_files') . '">Download File</a>'; 

In other words, just format the sub field as a link.