Hello, I’m using the basic display (URL) for the file:
<?php if( get_field('file') ): ?>
<a href="<?php the_field('file'); ?>" >Download File</a>
<?php endif; ?>
But I have it inside a repeater. When editing my page, I can add the new row, the other fields like text, textarea work, but I have tried all of the other variations of the file field and none seem to work. I verified that I’m using the correct custom field name and substituting it for “file” in the recommended code.
Is this a known bug or am I missing something, this seems pretty straightforward and all the other fields work.
Ok, ok, in classic form you know how after a couple of hours of banging your head and then posting in support as a final cry for help you stumble across the obvious answer.
Well, here it is in case anyone else is lost.
You need to make sure “SUB” is added to the code like so:
<?php if( get_sub_field('file') ): ?>
<a href="<?php the_sub_field('file'); ?>" >Download File</a>
<?php endif; ?>
So add “get_sub_field” and “the_sub_field” and it will work. You need to add “sub” for repeaters and adjust the code inside accordingly.