Wordpress wp.newPost无法使用XMLRPC添加标签

时间:2014-12-16 00:01:24

标签: php wordpress wordpress-plugin

我读过类似的问题,但没有快乐。我想在使用XMLRPC Api创建新帖子时添加标签。

我能够完美地发送所有其他参数,但标签不会添加。谢谢。

$params = array('post_type' => 'post',
            'post_status' => 'publish', 
            'post_title' => 'I like coffee',
            'post_content' => 'some more content here',
            'post_name' => 'complete name',
            'post_category' => array('2', '1'),
            'tags_input' => array('lemon', 'pear') 
            );

解决方案:这项工作

 $params = array('post_type' => 'post',
            'post_status' => 'publish', 
            'post_title' => 'I like coffee',
            'post_content' => 'some more content here',
            'post_name' => 'complete name',
            'post_category' => array('2', '1'),
            'terms' => array(   'category' => array('1', '2'),
                                'post_tag' => array('4', '3')
                            )
            );

1 个答案:

答案 0 :(得分:0)

 $params = array('post_type' => 'post',
        'post_status' => 'publish', 
        'post_title' => 'I like coffee',
        'post_content' => 'some more content here',
        'post_name' => 'complete name',
        'post_category' => array('2', '1'),
        'terms' => array(   'category' => array('1', '2'),
                            'post_tag' => array('4', '3')
                        )
        );