Codex tools: Log in / create account
Languages: English • Türkçe • (Add your language)
Contents |
This function updates posts (and pages) in the database. To work as expected, it is necessary to pass the ID of the post to be updated.
<?php wp_update_post( $post ); ?>
Before calling wp_update_post() it is necessary to create an array to pass the necessary elements. Unlike wp_insert_post(), it is only necessary to pass the ID of the post to be updated and the elements to be updated. The names of the elements should match those in the database.
// Update post 37 $my_post = array(); $my_post['ID'] = 37; $my_post['post_content'] = 'This is the updated content.'; // Update the post into the database wp_update_post( $my_post );
Categories need to be passed as an array of integers that match the category IDs in the database. This is the case even where only one category is assigned to the post.
The ID of the post if the post is successfully added to the database. Otherwise returns 0.