‘ID’
(int) 文章ID,如果不等于0则更新,等于0则创建,默认为0。
‘post_author’
(int) 添加文章的作者,默认为当前用户。
‘post_date’
(string) 文章添加日期,默认为当前日期
‘post_date_gmt’
(string) 在格林尼治时间区域中的时间,默认为 $post_date的值.
‘post_content’
(mixed) 文章内容,默认为空.
‘post_content_filtered’
(string) 过滤后的帖子内容。默认空.
‘post_title’
(string) 文章标题。默认空.
‘post_excerpt’
(string) 文章摘要。默认空.
‘post_status’
(string) 文章状态,默认为 ‘draft’.
‘post_type’
(string) 文章类型,默认为 ‘post’.
‘comment_status’
(string) 文章评论状态开关,默认是 ‘default_comment_status’ 配置项的值.
‘ping_status’
(string) ping状态开关,默认是’default_ping_status’ 配置项的值.
‘post_password’
(string) 文章阅读密码,默认为空.
‘post_name’
(string) 文章的名字。默认情况下,在创建新文章时,必须使用经过净化的文章标题.
‘to_ping’
(string) 空格或回车将url的列表分隔成ping,默认是空的.
‘pinged’
(string) 空格或回车分隔的url列表,默认是空的.
‘post_modified’
(string) 上次修改后的日期,默认是当前时间.
‘post_modified_gmt’
(string) 最后在GMT时区修改后的日期,默认是当前时间.
‘post_parent’
(int) 文章的父级文章ID,默认为 0.
‘menu_order’
(int) 如果新文章为一个页面,可以设置一个页面序号,默认为 0.
‘post_mime_type’
(string) 文章的mime类型,默认是空的.
‘guid’
(string) 全局唯一ID,用于引用post,默认是空的.
‘post_category’
(array) 文章分类目录,默认值为『default_category』选项的值.
‘tags_input’
(array) 文章标签,默认为空.
‘tax_input’
(array) 文章的自定义分类法项目,默认为空.
‘meta_input’
(array) 自定义字段,默认为空.
page_template
页面模板文件的名称,如,template.php,默认为空。
$wp_error

(bool) (Optional) 是否在失败时返回wp_error

默认值: false

返回值

(int|WP_Error)成功返回post_id,失败返回0或wp_error