I have been trying to import something into a custom field using the WordPress Import tool but it seems to be leaving the custom field empty in the database.
<wp:meta_value><![CDATA[a:19:{s:7:"address";s:50:"52, St. Michaels Rd,Sheffield,S359YN";s:11:"gpsLatitude";s:18:"";s:12:"gpsLongitude";s:18:"";s:18:"streetViewLatitude";s:9:"";s:19:"streetViewLongitude";s:18:"";s:17:"streetViewHeading";s:17:"";s:15:"streetViewPitch";s:18:"";s:14:"streetViewZoom";s:1:"0";s:9:"telephone";s:13:"01142570288";s:5:"email";s:19:"";s:3:"web";s:17:"";s:11:"hoursMonday";s:9:"";s:12:"hoursTuesday";s:9:"";s:14:"hoursWednesday";s:9:"";s:13:"hoursThursday";s:9:"";s:11:"hoursFriday";s:9:"";s:13:"hoursSaturday";s:6:"";s:11:"hoursSunday";s:6:"";s:18:"alternativeContent";s:0:"";}]]></wp:meta_value>
There doesn’t seem to be anything massive sticking out with this, but when I use the importer tool it ignores this and leaves an empty space in the database.
Any ideas of what’s happening or if there’s something blatantly obvious that’s missing?
I have recently had a lesson in serialized arrays from a friend and it all makes sense now!
After working this out it finally worked on the import.
Take this for example:
a:1:{s:7:”address”;s:50:”52, St. Michaels Rd,Sheffield,S359YN”;}
a:size:{key definition;value definition;(repeated per element)}
s:7:”address”; This is the the size of the value. So for address there are 7 characters in the word address so the value size is 7.
s:size:value;
There is also integer values shown like this:
Bolean values are shown like this:
that’s all there basically is in a serialized array to worry about, and when correct the wordpress importer will import these into the database with no problems, but if they are wrong then it escapes itself and leaves the field in the database row empty.
Examples: