Hey all,
I’m using the .editPost XMLRPC method to update my posts’ Custom Fields on WordPress and I’m having trouble getting the Relationship field data right.
When I look at the info from .getPost, I see fields like this:
<value><struct>
<member><name>id</name><value><string>369024</string></value></member>
<member><name>key</name><value><string>featured_shortcuts</string></value></member>
<member><name>value</name><value><string>a:1:{i:0;s:5:"24076";}</string></value></member>
When I pass the same serialized data back to add another post, like 4956 instead of 24076, it doesn’t accept the serialized data a:2:{i:0;s:4:"4596";i:1;s:5:"12965";}
and instead thinks the entire thing is one string, then serializes that to s:37:"a:2:{i:0;s:4:"4596";i:1;s:5:"12965";}";
.
I’m not sure what to do — is there another way to pass serialized data in? I’ve tried using "
instead of "
but that also doesn’t take properly; also using \"
doesn’t work either.
Even passing back the original a:1:{i:0;s:5:"24076";}
onto a new post doesn’t work.
Also, I am already correctly getting the id
of the value using getPost
and it seems to be saving the data and writing it even though it’s not correctly-formatted.
I’m going to preface this with “I don’t really know how to use XMLRPC in WP.
WP is serializing the value for you. Can you pass the value as an array? The value of a relationship field is an array of post IDs and the post ID values are strings.
array('24076')
I don’t really know why it’s returning a serialized value, it that something you can control?