我不会用SQL这样做。一个相对简单的PHP循环应该可以工作。
function bulk_schedule_posts_wpse_105834() {
$args = (
array(
\'cat\' => 1,
\'posts_per_page\' => -1,
\'post_status\' => \'draft\',
\'post_type\' => \'post\',
)
);
$posts = new WP_Query($args);
if (!$posts->have_posts()) return false;
$date = \'2013-08-01\';
$times = array(
\'10:00\',
\'14:00\',
\'17:00\',
\'20:30\'
);
while ($posts->have_posts()) {
global $post;
$posts->the_post();
if (0 !== $posts->current_post && 0 === $posts->current_post%4) {
$date = date(\'Y-m-d\',strtotime(\'+1 day\',strtotime($date)));
}
$thisdate = $date.\' \'.$times[$posts->current_post%4].\':00\';
$date_gmt = get_gmt_from_date($thisdate);
$post->edit_date = true;
$post->post_date = $thisdate;
$post->post_date_gmt = $date_gmt;
$post->post_status = \'future\';
wp_update_post($post);
}
}
bulk_schedule_posts_wpse_105834();
Run that function once and then remove it. 你所做的事是相当危险的。在现场使用之前,对虚拟数据进行彻底测试。我认为它实际上不应该破坏太多数据,但它可能会造成一片混乱。
几乎未经测试。可能是马车。买主注意事项。不退款。