从另一个数据库添加帖子到WP数据库


Adding posts to WP db from another db

我有一个~44k行数据库,我希望每一行都是一个帖子,这样我就可以将它们显示到wordpress中并轻松管理它们。我执行了下面的代码,它只向wp_posts中添加了约21k行,然后他停止了。我需要一种方法来移动整个数据库到wp_posts。什么好主意吗?

$results=$wpdb->get_results("SELECT * FROM `wp_doctors` ORDER BY `nume`");
foreach($results as $r){
// Create post object
$my_post = array(
'post_title'    => $r->nume,
'post_content'  =>  $r->spec.'</br>'.$r->institutie.'</br>'.$r->judet.'</br>'.$r->localitate,
'post_status'   => 'publish',
'post_author'   => 1,
'post_category' => array( 8,39 )
 );
 // Insert the post into the database and return the post id
  $post_id=wp_insert_post( $my_post, $wp_error );
}

我也认为是运行时描述杀死了你的脚本。

尝试:ini_set('max_execution_time', 0);(我认为这不会在共享主机上工作)

你也可以使用现有的解决方案,如Big Dump,它是用来处理大量数据的