数据库架构。
ID title keywords category body time
1 XX demo,tag main <html> NOW()
2 YY demo2,tag main <html> NOW()
此数据库经常被其他网络应用程序更新。
我的问题是我如何发布创建一个自定义的php文件,可以处理从这个表发布到wordpress的新记录?
当我用Google搜索时,我发现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 );}
那么有人可以解释一下如何将数据库导出到带有类别的wordpress帖子(如果不存在则创建),标签,标题,时间日期和内容?
非常感谢