我已经尝试了很长时间,但它仍然只发布为“未分类”,在文档中声明使用整数值作为类别 ID,但这不起作用。我也尝试按原样和小写字母编写类别名称,并输入 slug。根据文档,我做的一切都是正确的,但它仍然不起作用! wp. newPost并且因为它使用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 );
}