Skip to content

Instantly share code, notes, and snippets.

@danielmartins
Created March 18, 2013 01:22
Show Gist options
  • Save danielmartins/5184426 to your computer and use it in GitHub Desktop.
Save danielmartins/5184426 to your computer and use it in GitHub Desktop.
Wordpress: insert a new post programmatically
// Create post object
$newpost = array(
'post_title' => 'My post',
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_author' => 1, // admin
);
// Insert the post into the database
wp_insert_post( $newpost );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment