简体   繁体   中英

Adding posts to WP db from another db

i have a ~44k rows database and i want each row to be a post so i can display them into wordpress and manage them easily. I executed the following code and it added only ~21k rows into wp_posts and he stopped. I need a way to move the entire db to wp_posts. Any ideas?

$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 );
}

I also think it was the runtime description that killed your script.

Try: ini_set('max_execution_time', 0); (I think this would not work on shared hosting)

You could also use an existing solution like Big Dump which is made to handle huge amount of data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM