Php 通过XMLRPC发布Wordpress文章-添加多个类别

Php 通过XMLRPC发布Wordpress文章-添加多个类别,php,wordpress,xml-rpc,Php,Wordpress,Xml Rpc,我正试图通过XMLRPC向Wordpress(3.3.1)帖子添加多个类别 这是我的代码(工作正常,请阅读以下内容): 还有这个: $category = "telesync, dvdscr"; $category =array('telesync','dvdscr'); 如何向帖子添加多个类别? 谢谢大家! 我在测试了其他一些选项后找到了答案,如: 'categories'=>array("telesync", "1080p"), $content变量如下所示: $content

我正试图通过XMLRPC向Wordpress(3.3.1)帖子添加多个类别

这是我的代码(工作正常,请阅读以下内容):

还有这个:

$category = "telesync, dvdscr";
$category =array('telesync','dvdscr');
如何向帖子添加多个类别?
谢谢大家!

我在测试了其他一些选项后找到了答案,如:

'categories'=>array("telesync", "1080p"),
$content变量如下所示:

$content = array(
    'title'=>$title,
    'description'=>$body,
    'mt_allow_comments'=>0,  // 1 to allow comments
    'mt_allow_pings'=>0,  // 1 to allow trackbacks
    'post_type'=>'post',
    'mt_keywords'=>$keywords,
    'categories'=>array("telesync", "1080p"), // I've typed the categories directly here.
    'custom_fields' =>  array($customfields)


);

我知道这有点晚,但对于那些遇到相同问题的人来说,第一个猜测是最好的解决方案(与其直接键入类别,不如将其作为变量传递):

我们只需删除
categories=>array($category)
上的'array',因为我们已经将
$category
声明为数组。因此,不是:

'categories'=>array($category),
使用:

它应该会起作用

$category =array('telesync','dvdscr');
'categories'=>array($category),
'categories'=>$category,