Home Forums General Issues Building XML for import to WordPress/ACF Pro


Building XML for import to WordPress/ACF Pro

  • Hi there, I had a search of forums, but couldn’t find an answer.

    I’m exporting XML with image metadata from an instance of WordPress that doesn’t use ACF Pro for images, and I’d like to import it into a new WordPress instance, but using ACF Pro for galleries, using those images (which to be clear, weren’t in image galleries before).

    I know the target XML for the image gallery looks like this:

    <wp:meta_value><![CDATA[a:76:{i:0;s:4:”7992″;i:1;s:4:”7977″;i:2;s:4:”7972″;i:3;s:4:”7946″;i:4;s:4:”7953″;i:5;s:4:”7934″;s:4:”7921″;i:8;s:4:”7879″;}]]></wp:meta_value> </wp:postmeta>

    So I’ve built a Ruby script that can take the old image data, and generate XML in the above form. But I’ve got a couple of missing bits of info.

    I know that:
    “i” refers to the index, which simply increments.
    “s” probably refers to a size
    and the large number in quotes is the image id association.

    But I’m not sure what “a” refers to? Can someone advise?

    (also, any commentary on whether there’s an easier way to do this is welcome, and happy for thread to be moved to different sub-forum)

    Many thanks,

  • Actually, that is a serialized array and if you do a search you can get information on how this is put together.

    Here I will break down some of what you posted, which actually appears to be incorrect. I’m basing this on what you posted, so, this is just general. Also

    array:76 elements:{
    integer: value = 0
    string: string length: string value

    See look at the user comments for more explanations.

    If the value is not properly serialized, if there is an error, then the entire value is ignored as if it does not exist. Trying to unserialize the string you created causes an internal server error, which is odd, must be something

  • Hi Dave,

    The “a” means array, which means how many items (array length) it has. This page should give you more idea about it:

    Another method would be using the update_field() function instead. Just make sure that you use the field key instead of the field name.

    I hope this helps 🙂

  • That’s great guys, thanks for the help. I will investigate further and report back.

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

You must be logged in to reply to this topic.