2010-04-07 113 views
0

我正嘗試通過XMLRPC使用WordPress API來提交新帖子。但我無法設置帖子標籤(也沒有分類)。在提交帖子時,通過XMLRPC API在wordpress中設置帖子標籤?

 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); 

有什麼想法嗎?

回答

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; 

多個電子郵件:[email protected]

1

您還可以設置自定義字段這樣

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