I've been trying for quite a long time and still it posts only as "Uncategorized", In the documentation it's stated to use integer value as category ID, but that doesn't work. I've also tried writing category name as it is and in lowercase and also entering slug. According to documentation I'm doing everything right, but it still doesn't work! wp.newPost and since it uses wp_insert_post().
public function create_post( $title, $body )
{
$title = htmlentities( $title, ENT_NOQUOTES, 'UTF-8' );
$content = array(
'post_category' => array( 18 ), // my category id
'post_type' => 'post',
'post_status' => 'pending',
'post_title' => $title,
'post_content' => $body,
'comment_status' => 'closed',
);
$params = array( 0, $this->username, $this->password, $content );
return $this->send_request( 'wp.newPost', $params );
}
Thanks, this is a life saver! If you need to provide tags for your post, you can pass them in array using
tags_input
property, like this:If you need to pass in a specific time stamp, you should use the following format
and pass it using the
post_date
orpost_date_gmt
property:Hope it helps someone in the future!
Hey I've recently started using the new API.
You should use the terms_names parameter in your XML-RPC request as stated in the new docs:
http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.newPost
Example:
Your code should be changed to look something like this.
I have one problem with this API method however, the Post ID is not returned only a false boolean value. Let me know if you have any luck with inserting categories and if you manage to receive the POST ID.