我制作了一个php脚本,在wordpress网站上发布了一篇新文章。
这是我的代码的一部分:
$terms_names = array('post_tag' => $tags);
$content = array(
'post_type' => 'post',
'post_status'=>'pending',
'post_title'=> 'TEST',
'post_author'=> 1,
'post_excerpt' => 'SOMETEXT',
'post_content'=> 'POSTBODY',
'post_date_gmt' => '',
'comment_status'=>1
'ping_status'=>0,
'post_thumbnail' => $results,
'terms_names' => $terms_names
);
$params = array(0,$username,$password,$content,false);
$request = xmlrpc_encode_request('wp.newPost',$params);
是否可以添加帖子标签? 感谢所有
此致
修改
问题解决了:)
我添加了$terms_name
数组,
我刚刚编辑了我的代码:)
此致
答案 0 :(得分:0)
只需在您的数组中添加标签(编辑:作为数组或不使用<>)
$tags = array('tag1', 'tag2');
$content = array(
'post_type' => 'post',
'post_status' =>'pending',
'post_title' => 'TEST',
'post_author' => 1,
'post_excerpt' => 'SOMETEXT',
'post_content' => 'POSTBODY',
'post_date_gmt' => '',
'comment_status'=> 1
'ping_status' => 0,
'post_thumbnail'=> $results,
'tags_input' => $tags
);
wp.newPost接受wp_insert_post
支持的所有文件