1

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()?

3

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 );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.