Support

Account

Home Forums ACF PRO How to edit custom image (attachment) meta?

Solved

How to edit custom image (attachment) meta?

  • I’ve used a function to add photographer name and URL (extra custom meta) to uploaded images.

    The added data can be retrieved using get_post_meta($id,'photographer',true), for example.

    These two meta fields also display in ACF. Which is great, until I go to edit them. The values are not saved on Publish.

    I guess that because these values are not added to the ACF image array, ACF can’t save them.

    How would I (can I?) go about adding these key => value pairs to ACF’s image array, or whatever else I’d need to do to make these fields editable and save-able as they appear to be in the UI?

    Just one thing. I don’t want to be trapped into having to do little tweaks to an ACF supporting file every time ACF is updated to keep the fix working.

  • Hi @ht,

    Thanks for the post.

    To add or update meta within ACF fields, I would recommend you make use of the update_field() function. This functions accepts three parameters, in your case, you will need to pass the field_key, $value and the post id that you want to update the posts to.

  • Thanks, James. Elliot actually fixed the issue shortly after my question, but your tip could be valuable at another time.

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

You must be logged in to reply to this topic.