Support

Account

Home Forums Front-end Issues Having trouble when adding data directly into database.

Solving

Having trouble when adding data directly into database.

  • I am importing data from an outside source to populate my custom fields meta data. They show up when editing (back end), but not on the post output (front end) until I physically hit update. I compared the post_meta data before and after the update and am adding the same database fields that get added on update, but they still are not showing up until I physically hit update.

    In my case it’s a repeater field and I have the following data

    photo_slider
    _photo_slider
    photo_slider_0_photo
    _photo_slider_0_photo
    photo_slider_1_photo
    _photo_slider_1_photo
    etc….

    What else am I missing. Is there something else I need to update for ACF to recognize the data for output? I am also updating the parent post modified dates.

  • Are you using the update_field() function to set the value when you populate the custom fields during import?

    If so, are you using the field_key value such as:

    
    $field_key = "field_5039a99716d1d";
    $value = "some new string";
    update_field( $field_key, $value );
    

    Full docs: http://www.advancedcustomfields.com/resources/update_field/#finding-the%20field%20key

  • No, we are dumping it directly into the database from an external source.

    I am matching as far as I can tell what is being input after an update.

  • I will also add, we are doing the exact same thing for another repeater field and that one is working. The only difference being, we are storing postid (for images) in the one that isn’t working, and text data in the one that is. Since they are both arrays, I assume that shouldn’t matter.

  • Any suggestions? I am at a loss. I have populated the database post_meta table to look exactly the same as if I had hit update and it’s still not showing up. I have also updated the post modified dates. Is there any other tables, information that needs to update for ACF to recognize the fields?

  • In your repeater that is not working (the one storing post id for images) do the images exist in the media gallery with those IDs?

  • Yes, the images do exist and have IDs associated which is what we are populating the meta_value with. The post_meta table looks exactly the same after update, but for some reason, we physically have to hit update to make the repeater field recognize the data. That makes me think there is something somewhere else that needs to be updated.

    The images even show up when in edit mode before hitting update, and in preview mode, just not on the front end page until after updating.

  • If I wanted to use this method outside of wordpress, what file would I need to include to pull in the update_field method?

  • I am STILL having this issue. I am using a script to populate the post meta data from an external source and about half the fields don’t show up until I physically edit the post and hit update but the values are showing in the fields. Any idea how to fix this?

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

The topic ‘Having trouble when adding data directly into database.’ is closed to new replies.