wp_update_post( array|object $postarr = array(), bool $wp_error = false, bool $fire_after_hooks = true )
Updates a post with new post data.
Description
The date does not have to be set for drafts. You can set the date and it will not be overridden.
Parameters
- $postarr
-
(Optional) Post data. Arrays are expected to be escaped, objects are not. See wp_insert_post() for accepted arguments.<br> Default array.
Default value: array()
- $wp_error
-
(Optional) Whether to return a WP_Error on failure.
Default value: false
- $fire_after_hooks
-
(Optional) Whether to fire the after insert hooks.
Default value: true
Return
(int|WP_Error) The post ID on success. The value 0 or WP_Error on failure.
Source
File: wp-includes/post.php
Changelog
Version | Description |
---|---|
5.6.0 | Added the $fire_after_hooks parameter. |
3.5.0 | Added the $wp_error parameter to allow a WP_Error to be returned on failure. |
1.0.0 | Introduced. |