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.


Top ↑

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


Top ↑

Changelog

Changelog
VersionDescription
2.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.