I have created a WYSIWYG field “gallery” where I want to upload default WordPress gallery.
I have a lot of posts and I would like to use a import/export third party plugin (“WP CSV“) to import my posts from a CSV file.
The plugin can export custom post type where I find my custom field “gallery”.
When I put the default WordPress gallery code [gallery link="file" columns="4" ids="756,755,754,753"] in the “gallery” column, my gallery don’t appear as expected. I have instead [gallery columns="4" ids="767,768,769,770"] as a text, not as a gallery.
That is strange because, in the backend, the images appear, but not in the frontend.
I have to update manually each post so that the gallery appear.
Does anybody could help me?
I post my issue in this forum because when when I copy the gallery code in “post_content” column, it works like a charm.
I don’t know the solution. Figured I’d post something because I recently looked at doing the same thing.
I was building my own code to do the importing from a CSV, the main reason for this is that most of the plugins available do not really understand how to import data for ACF (even if they say they do) especially for things like repeater fields. Or for that matter importing attachments.
Anyway, I dug through everything looking for something that got stored in the DB to tell WP that there was a gallery there. I went as far as going through the steps of creating a WP gallery in a post, exporting the DB at every step and comparing the exports for any differences and doing the same thing for my imported data. I could find no reason for the gallery shortcode to not be processed properly from my import.
No matter what I did I found that the only way to get WP to recognize the gallery was to open and save every post. Not a very good solution for the client that was importing 800+ products all with a gallery.
I finally gave up, but I’d also really like to understand what I’m missing to get this done because I’m sure I’ll revisit this in the future. I don’t think this is really an ACF issue though, I’m sure it’s something to do with WP and some bit of data I’m missing somewhere, somehow.
There is one thing that I did not try now that I think about it. For every field you create ACF creates 2 fields in the postmeta table when you add values to a post. the first is the field name you created, for example “my_gallery_field”. The second is a has a key of “_my_gallery_field” and this one’s value is the ACF “key” value for your field. I know that for repeater fields that all fields, including the ACF key references need to be inserted into the database to make them work. I will give this a shot the next time I’m working on my import script. Could be a while before I get to it though. But maybe something you can try.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
ACF PRO’s Flexible Content field allows you to create smaller pieces of UI and compose them into whole flexible patterns. In our latest article, we show how to use it to create swappable site sections and integrate it all in a theme.https://t.co/ZRocH8oJSp— Advanced Custom Fields (@wp_acf) January 24, 2023
© 2023 Advanced Custom Fields.