将自定义 Wordpress 编辑器提交到 wp-admin/post。php

Submit custom Wordpress Editor to wp-admin/post.php

我正在尝试在自定义主题页面上获得一个可用的 post 编辑器。编辑器本身可以工作(使用 wp_editor()),但如果我将 action="/wp-admin/post.php" 添加到表单和以下隐藏字段:

_wpnonce (wp_create_nonce()), post_type, originalaction, post_author, ... post.php 页面显示 Are you sure you want to do this?. 如果我只发送我被重定向到 wp-admin/edit.php 但没有创建 post 的内容...

所以我的问题是;是否有可能制作一个自定义的 wordpress 编辑器提交给现有的 wp-admin/post.php,或者我是否必须自己捕获内容并上传并通过 PHP 创建 post ?

我找到了解决方案并按如下方式解决:表单针对我的主题主页,我在 functions.php 中手动处理表单数据(index.php 当然也可以) :

$post_options = array(
    'post_title'    => wp_strip_all_tags($_POST['post_title']),
    'post_content'  => $_POST['post_content'],
    'post_status'   => 'publish',
    'post_author'   => get_current_user_id(),
    'post_category' => []
);

$new_post = wp_insert_post($post_options);

if (!is_wp_error($new_post)) {
     // success
}