管理画面やアプリからでなく、phpスクリプトから直接投稿するには「wp_insert_post()」を使用します。
引数には配列をひとつ指定します。
指定する配列はこんなかんじです。
1 |
$post = array( 'ID' => [ ] // 既存の投稿を更新する場合。 'menu_order' => [ ] // 追加する投稿が固定ページの場合、ページの並び順を番号で指定できます。 'comment_status' => [ 'closed' | 'open' ] // 'closed' はコメントを閉じます。 'ping_status' => [ 'closed' | 'open' ] // 'closed' はピンバック/トラックバックをオフにします。 'pinged' => [ ? ] // ピンバック済。 'post_author' => [ ] // 作成者のユーザー ID。 'post_category' => [ array(, ) ] // カテゴリーを追加。 'post_content' => [ ] // 投稿の全文。 'post_date' => [ Y-m-d H:i:s ] // 投稿の作成日時。 'post_date_gmt' => [ Y-m-d H:i:s ] // 投稿の作成日時(GMT)。 'post_excerpt' => [ ] // 投稿の抜粋。 'post_name' => [ ] // 投稿スラッグ。 'post_parent' => [ ] // 親投稿の ID。 'post_password' => [ ] // 投稿の閲覧時にパスワードが必要になります。 'post_status' => [ 'draft' | 'publish' | 'pending'| 'future' ] // 公開ステータス。 'post_title' => [ ] // 投稿のタイトル。 'post_type' => [ 'post' | 'page' ] // 投稿タイプ名。 'tags_input' => [ ', , ' ] // 投稿タグ。 'to_ping' => [ ? ] //? ); |