在提交帖子时通过XMLRPC API在wordpress中设置帖子标签?

时间:2010-04-07 10:18:28

标签: php api wordpress xml-rpc

我正在尝试通过XMLRPC使用WordPress API来提交新帖子。但我无法设置帖子标签(也不能设置类别)。

        echo "Adding $term to blog via XMLRPC ...";
        $client = new IXR_Client("http://$blog.wordpress.com/xmlrpc.php");
        $content = array('title'=>$term,
                         'description'=>"All about $term",
                         'category'=>'barvaz,moshe',
                          'tags'=>'tag1,tag2');
        $client->query('metaWeblog.newPost', 0, $username, $password, $content, true);
        $rv = $client->getResponse();
        print_r($rv);

有什么想法吗?

2 个答案:

答案 0 :(得分:3)

$categories[0]="cate1";
$categories[1]="cate2";

$tags[0]="tag1";
$tags[1]="tag2";


...
$content['title'] = $title;
$content['categories'] = $categories;
$content['mt_keywords'] = $tags;
$content['description'] = $description; 

更多电子邮件:cn.xiaowen@gmail.com

答案 1 :(得分:1)

您也可以像这样设置自定义字段

$content['custom_fields'] = array(
        array('key' => 'Image', 'value' => $img),
        array('key' => '_aioseop_keywords', 'value' => $aiokey),
        array('key' => '_aioseop_title', 'value' => $title),
    );