Support

Account

Home Forums General Issues Bulk Importing Data with File Fields

Solving

Bulk Importing Data with File Fields

  • Hello, I’m using the WP All Import plugin to mass import a lot of data. It works great, but I’m having an issue with file fields. I imagine the same thing would happen for image fields.

    I have a field group set up with one field being a file. I have set it to be a file URL. When I do the import, the value for the file URL is imported correctly. And if I search for the meta_key / meta_value pair in the database, I see what I’d expect.

    The problem is on the editing side of things. If you go to edit an imported record, the interface does not recognize that the file field has a value. The file itself is in the Media Library and, as noted, the value is listed in the database. So why doesn’t the file interface display the selected field?

    Ah-ha. The plot thickens. One of the custom post type records file field had been edited to select a file, so that now if you go to the edit view, you do see a file selected there. If I search for that meta_key and that post_id in the database, I don’t any results. So are ACF file and image fields not stored in the wp_postmeta table?

    Thanks.

  • I found it… The file is stored in the wp_posts table as a post_type of attachment and a post_parent ID of the record in question. I think I’m still missing something, though, because I still don’t see how it is tied to the field itself…

  • All right, I think I found all the connections…

    We’ve got:

    1. Original custom post in wp_posts with post_type = ‘publication’, in my case. In my example, the ID = 1171.
    2. File is stored in wp_posts as well with post_type = ‘attachment’. I see post_parent = 1171 and ID = 1264.
    3. File is associated with the correct field a) in the wp_postmeta table with a post_id = 1264 and a meta_key = ‘_wp_attached_file’. The meta_id = 6000.
    4. AND in b) the wp_postmeta table with a post_id = 1171 and meta_key = ‘publication_download_file’ (my field name) and a meta_value = 1264
  • Hey guys.

    Just as a tip, you can use the update_field function (please see docs) to save a value to the post

    All you need to do is save the attachment ID

    Good luck!

  • Thanks, Elliot! I will give this a shot.

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

The topic ‘Bulk Importing Data with File Fields’ is closed to new replies.