Here is my script :

$my_post = array(
                'post_title' => "post test",
                'post_date' => current_time('mysql'),
                'post_content' => 'This is my post.',
                'post_status' => 'publish', 
                'post_author'   => 1,
                'post_category' => array(1)

            ); 
        $post_id= wp_insert_post($my_post);
        var_dump($post_id);

2 Answers
2

Remove the date param or use the right format for the time stamp, like date('Y-m-d H:i:s'), But it is not necessary, WP use the current timestamp on the insert post time.

Leave a Reply

Your email address will not be published. Required fields are marked *