Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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 );
share|improve this answer
    
And wp_insert_post‌​, as the name suggests ;) –  TheDeadMedic Jun 25 '11 at 17:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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