Support

Account

Home Forums General Issues Including ACF data for media

Solving

Including ACF data for media

    • ycrad

    • December 6, 2020 at 5:28 pm

    Hello,

    I have successfully been able to update ACF for custom post types using the REST API. However, when trying the same method for media, it hasn’t worked.

    Can you insert ACF data for media using the REST API? If so, what approach do you take?

    This is the code I’m using

    const route =${API_URL}media/${id}`;
    const body = {
    status: ‘publish’,
    fields: {
    job_code: ${job_code},
    },
    };

    const res = await fetch(route, {
    method: ‘POST’,
    headers: {
    ‘Content-Type’: ‘application/json’,
    Authorization: Bearer ${token},
    },
    body: JSON.stringify(body),
    });`

  • @ycrad Did you manage to find a solution to this? I am experiencing the exact same issue.

    Updating ACF fields to post types other than media works fine, but doesn’t with the same approach applied to the media endpoint.

    • ycrad

    • March 3, 2021 at 10:11 am

    @pickerro98 No, unfortunately I never found a solution for this. We ended up not using ACF as a result!

  • tried the acf to rest api?
    https://wordpress.org/plugins/acf-to-rest-api/

  • “Media” is a post just like any other post with a post type of “attachment”. You would add ACF field to it the same as you add them to any other post.

Viewing 5 posts - 1 through 5 (of 5 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.