Support

Account

Home Forums General Issues Saving additional data along with field data.

Helping

Saving additional data along with field data.

  • Are there any recommended ways to store additional meta data that corresponds to a field instance.

    For example, I might have a ‘video_url’ field, and additionally I want to grab the videos thumbnail from a 3rd part api. However, I don’t want to do this every time I load the value in a template as it quickly becomes costly when you are loading multiple instances.

    My current solution is to hide an additional field by way of an impossible combination of conditional properties.

    I can then use the save_post filter to update one value according to the other.

    This however doesn’t seem like the cleanest way to go about things, and I am wondering if anyone can suggest a more standard way to go about this.

    Thanks,

  • Hi @influencebydesign

    Hmm… Try using acf/update_value to update the field value into an array and add the extra meta data into this array then serialize the array and return the serialize value.

    Then use acf/load_value filter to un-serialize the value and return it to the template functions.

    Here are the links to the docs for these filters:
    http://www.advancedcustomfields.com/resources/acfupdate_value/
    http://www.advancedcustomfields.com/resources/acfload_value/

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

You must be logged in to reply to this topic.