Home Forums ACF PRO File field not saving/displaying correctly


File field not saving/displaying correctly

  • Hi guys,

    I’m using the latest version of both WordPress and ACF (4.5.1 and 5.3.7 respectively). I’m also using the latest version of Timber for my ‘starter theme’ (v. 0.22.6).

    I have a Calendar custom post type. It’s pretty simple: the user just needs to basically upload a PDF file to each new monthly calendar post. At first I used the basic media library to add the PDF to the post, but I want more control over it. So I created a custom field group with ACF and made a File field. Told it only .pdf files may be updated.

    At first I told it to save it as an array. Couldn’t get it to work.
    Then tried URL, still didn’t work.
    Then I tried saving it as its ID, doesn’t work. Timber suggests using the ID method for images, so I was hoping maybe that’d work with the file field.

    What happens is it only returns what looks like the ID of the file. I created two posts, uploaded two different PDF files, and each one just returns “26” and “32”.

    I opened MySQL Workbench and looked in the wp_postmeta table, and here’s what I find:

    _calendar_file     =>  field_5724d19...
    calendar_file      =>  32
    _wp_attached_file  =>  2016/05/file.pdf

    Why is the actual calendar_file field saving “32”? I don’t see any other row showing 32 as some sort of ID for it.

    All I want to return is the URL to the file. What am I missing?

    Thank you!

  • Sorry, it was due to a silly oversight.

    After trying so many different things I managed to get it to work by simply doing {{post.get_field('calendar_file')}}.

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

The topic ‘File field not saving/displaying correctly’ is closed to new replies.