How can I update/add a new title, post content, and category to a post with hard PHP code similar to add_post_meta(), update_post_meta()?
1 Answer
By using wp_update_post()
, found in wp-includes/post.php:
// Update post 42
$post = array();
$post['ID'] = 42;
$post['post_category'] = array( ... );
$post['post_content' ] = 'This is the updated content.';
$post['post_title' ] = 'This is the updated title.';
// Update the post into the database
wp_update_post( $post );