When I use wp_insert_post() I get a white page that says “Are you sure you want to do this?”. I get no PHP errors. I am using this outside of wordpress and have wp-load.php as well as /wp-admin/includes/file.php included.
My code looks like this.
require_once $_SERVER['DOCUMENT_ROOT'] . "/wp-load.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/wp-admin/includes/file.php";
$imagePost = array(
'post_title' => "Test",
'post_content' => 'Content added later.',
'post_status' => 'publish',
'post_author' => 1,
'tags_input' => "'test'",
'post_category' => array(1),
'post_type' => 'post'
);
$postID = wp_insert_post($imagePost, true);
Any help is much appreciated.
Just add this code