Support

Account

Home Forums Bug Reports File doesn't appear to work inside a repeater

Helping

File doesn't appear to work inside a repeater

  • 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.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.