データベース スキーマ。
ID title keywords category body time
1 XX demo,tag main <html> NOW()
2 YY demo2,tag main <html> NOW()
このデータベースは、別の Web アプリケーションによって頻繁に更新されます。
私の質問は、このテーブルからワードプレスへの新しいレコードの投稿を処理できるカスタム php ファイルを作成するにはどうすればよいですか?
グーグルで検索したときにwp_insert_post APIを見つけましたが、そこにない場合、これはカテゴリを作成しないと彼らは言いました。
foreach($data as $db){
$my_post = array();
$my_post['post_title'] = $db->title;
$my_post['post_content'] = $db->body;
$my_post['post_status'] = 'publish';
$my_post['post_author'] = 1;
//$my_post['post_category'] = array(8,39);//how to fetch the category id !
//$my_post['tags_input'] = explode(',',$db->keywords);///IS THIS CORRECT??
// Insert the post into the database
wp_insert_post( $my_post );}
カテゴリ(存在しない場合は作成)、タグ、タイトル、日時、コンテンツを含むワードプレスの投稿にデータベースをエクスポートする方法を説明してください。
どうもありがとう