我有一个数组$unqiues
其中包含URL,我使用下面的代码循环数组以获取URL标题,插入新帖子,更新帖子元。然后,我将帖子标题和名称更改为wp\\u insert\\u post返回的$pid。
这创建了一个无休止的循环,我在$unique数组中有大约600个或更少的URL。我在主机上一个小时内就完成了75000个查询,必须等待一个小时才能重置限制。是什么导致了无休止的循环?当我使用数组中的10个URL进行测试时,这段代码起到了作用。
如何更有效地编写?
谢谢
foreach($uniques as $unique){
$pagetitle = getTitle($unique);
$new_post = array(
\'post_title\' => $unique,
\'post_status\' => \'publish\',
\'post_type\' => \'websites\'
);
$pid = wp_insert_post($new_post);
update_post_meta($pid,\'title\', $pagetitle);
update_post_meta($pid,\'url\',$unique);
$my_post = array(
\'ID\' => $pid,
\'post_title\' => $pid,
\'post_name\' => $pid
);
wp_update_post( $my_post );
}