Skip to content

Instantly share code, notes, and snippets.

@ivarvong
Created November 16, 2010 04:01
Show Gist options
  • Save ivarvong/701391 to your computer and use it in GitHub Desktop.
Save ivarvong/701391 to your computer and use it in GitHub Desktop.
Create WordPress draft post from XHR post
<?php
require( '../wp-load.php' );
$stringData = $_POST['data'];
// Create post object
$my_post = array();
$my_post['post_title'] = 'TITLE CHANGE ME';
$my_post['post_content'] = $stringData;
$my_post['post_status'] = 'draft';
$my_post['post_author'] = 1;
$my_post['post_category'] = array(0);
// Insert the post into the database
if ($stringData != "") {
wp_insert_post( $my_post );
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment