Heading
=======
##H|eading 2|
####Heading 4
我试图根据post_type条件将$ message_array中的随机消息添加到此WP表中。没有任何事情发生。
答案 0 :(得分:0)
使用wpdb->更新..
while ($count <= 18614) {
$random_message = $message_array[mt_rand(0, count($message_array) - 1)];
$cell_type_pre = $conn->get_results("SELECT `post_type` FROM `wp_posts` WHERE `id` = " . $count);
$cell_type = $cell_type_pre[0]->{"post_type"};
if ($cell_type == "post") {
$conn->update('wp_posts', array('post_excerpt' => $random_message),array( 'ID' => $count, 'post_excerpt' => ''));
}
if ($cell_type == "attachment") {
$conn->update('wp_posts', array('post_content' => $random_message),array( 'ID' => $count, 'post_content' => ''));
}
$count++;
}