我有一個〜44k行數據庫,我希望每一行都是一個帖子,所以我可以將它們顯示到wordpress中並輕鬆管理它們。我執行了下面的代碼,它只添加了〜21k行到wp_posts並停止了。我需要一種方法將整個數據庫移動到wp_posts。有任何想法嗎?從另一個數據庫向WP db添加帖子
$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);
}
可能這是由於的max_execution_time,請在php.ini中的max_execution_time和增加它與嘗試.. –