简体   繁体   中英

Setting post tags in wordpress via XMLRPC API when submitting a post?

I am trying to use WordPress API via XMLRPC to submit new posts. But i can't set the post tags (nor the categories).

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

Any idea?

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

more email : cn.xiaowen@gmail.com

You also can set custom field like this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM