write_post() WordPress Function
The write_post() function is used to create or update a post in WordPress. This function can be used to create a new post, or update an existing post. The function takes two arguments: the post ID and the post data. The post data is an array of data that includes the post title, content, author, etc.
write_post() #
Calls wp_write_post() and handles the errors.
Return
(int|void) Post ID on success, void on failure.
Source
File: wp-admin/includes/post.php
function write_post() {
$result = wp_write_post();
if ( is_wp_error( $result ) ) {
wp_die( $result->get_error_message() );
} else {
return $result;
}
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 2.0.0 | Introduced. |