I’m using WordPress XML-RPC to automatically post to my blog and I got these two functions working from PHP: wp.newPost and wp.uploadFile.
However, when I run them in one php script as shown below: (just included the important parts) WordPress is not detecting attachment_id from wp.uploadFile when I try to post even though attachment_id exists.
//wp.newPost content
$content = array(
'post_title' => $title,
'post_content' => $body,
'post_status' => 'publish',
'post_type' => 'products',
'post_thumbnail' = // wp.uploadFile is called here that returns attachement id
);
$this->Curl->post($url,$content);
When I try to run above code I get: ” faultCode 404 faultString Invalid attachment ID. “
I verified that the wp.uploadFile image has been uploaded successfully and its showing in the WordPress library. In fact, if I run the script again and just replace the ‘post_thumbnail’ value with the same exact attachement_id that was return by wp.uploadFile, it works!
So, apparently WordPress is not detecting that the image has been uploaded if I run the two functions in conjunction as shown above. Is there any solution to this? I would really hate to store WordPress attachement id’s in my own database.
to post via xmlrpc i’m using IXR
the below is what i’m using; it will need certainly some edits but might give you some clue
to upload a new file:
to create a new post:
hope this helps!
(i’m now stuck with attaching images to post)