I'm using wp all import to load in datafeeds but when i set a custom field (thats needed for the theme) it keeps modding it before it stores it

when I put this in the field : a:7:{test}

it saves it as s:10"a:7:{test}"

Even when I update thru update_post_meta and set it there manually it adds the s:10...

How can I fix this, do I have to encase the string somehow? The custom field is same for each post is there some other way I can set it for each post in the php of the feeder?



in php will fill the field with s:10:"a:7:{test}" insteed of just a:7:{test}


update_post_meta is maybe_serialising.

And in this case is storing it as a serialised string

The string your passing isn't a correctly serialised array.

If you pass it the raw array it will self convert it to the correct serialised string.

The correct string is a:1:{i:0;s:4:"test"}, passing that shouldn't serialise but probably will. You are betted off passing in the array as an array

If you want to store an already serialised object, direct Database write.


When updating metadata, maybe_serialize() is applied (see source). This serialises any array/string but will also double serialize serialized data.

You should just pass an actual array.

If you have a serialised array which you want to unserialize, you can use maybe_unserialize(). That said, as has been pointed out, a:7:{test} is not a correctly serialised array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.