write_post

函式
write_post ( No parameters )
返回值
  • (int|void) Post ID on success, void on failure.
定義位置
相關方法
wp_write_postthe_postwp_remote_postedit_postsanitize_post
引入
2.0.0
棄用
-

write_post: 這個函式用於在WordPress部落格中寫一個新的文章。它把文章ID、文章標題、文章內容、文章摘要、文章作者、文章日期、文章狀態、文章型別和文章格式作為引數,並把一個新的文章寫到資料庫中。

呼叫wp_write_post()並處理錯誤。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function write_post() {
$result = wp_write_post();
if ( is_wp_error( $result ) ) {
wp_die( $result->get_error_message() );
} else {
return $result;
}
}
function write_post() { $result = wp_write_post(); if ( is_wp_error( $result ) ) { wp_die( $result->get_error_message() ); } else { return $result; } }
function write_post() {
	$result = wp_write_post();
	if ( is_wp_error( $result ) ) {
		wp_die( $result->get_error_message() );
	} else {
		return $result;
	}
}

常見問題

FAQs
檢視更多 >