How do I programmatically insert a post in WordPress using PHP?


 'My new post',
 'post_content' => 'Content to insert.',
 'post_status' => 'publish'
);
$post_id = wp_insert_post( $new_post );

if( $post_id ){
 echo "Post inserted successfully with the post ID of ".$post_id;
} else {
 echo "Error, post not inserted";
}

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!

Share This