Skip to content Skip to sidebar Skip to footer

How To Create A Post In Wordpress Programmatically

I would like to know how I create posts in WordPress programmatically for around seven different posts? I tried:

Solution 1:

global $user_ID;
$new_post = array(
'post_title' => 'My New Post',
'post_content' => 'Lorem ipsum dolor sit amet...',
'post_status' => 'publish',
'post_date' => date('Y-m-d H:i:s'),
'post_author' => $user_ID,
'post_type' => 'post',
'post_category' => array(0)
);
$post_id = wp_insert_post($new_post);

Post a Comment for "How To Create A Post In Wordpress Programmatically"