WordPress函数wp_insert_post用于插入一篇新的文章。 wp_insert_post( array $postarr, bool $wp_error = false, bool $fire_after_hooks = true ) 函数参数$postarr 数组 ID:文章的ID,如果传递0以外的值,则更新相应ID的文章而不是插入新的文章; post_author:作者的ID,默认为当前作者; post_date:发表时间,格式为Y-m-d H:i:s,默认为当前时间; post_date_gmt:发表文章的格林时间,与国内时区相差8小时; post_content:文章内容; post_content_filtered:文章内容过滤; post_title:文章标题; post_excerpt:文章摘要; post_status:文章状态,默认值:draft post_type:文章类型,默认值:post comment_status:是否允许评论,可用值:open或closed,默认取wp_options表中default_comment_status的值,即后台讨论设置中“允许他人在新文章上发表评论”选项; ping_status:是否允许其他博客发送链接通知,可用值:open或closed,默认取wp_options表中default_ping_status的值,即后台讨论设置中“允许其他博客发送链接通知(pingback和trackback)到新文章”选项; post_password:访问密码,默认为空; post_name:文章别名; to_ping:使用空格或回车分隔要ping的URL列表; pinged:空格或回车分隔已ping的url列表; post_modified:文章的修改时间,格式为Y-m-d H:i:s,默认为当前时间; post_modified_gmt:修改文章的格林时间; post_parent:父级ID; menu_order:文章的显示顺序; post_mime_type:MIME类型,适用于插入附件时; guid:文章链接,当设置固定链接后为伪静态格式,默认为动态链接; post_category:数组,文章分类的ID; tags_input:数组,标签名称、别名或ID; tax_input:数组,自定义分类法名称; meta_input:数组,post meta的键值对; $wp_error …