Question

I have a lot of posts everyday to publish. Now, I am thinking to schedule all those posts which I saved them as drafts. So, I tried to make a custom post scheduler. Here is what I tried,

$time = strtotime('+5 min');  

$args = array('post_type' => 'post','post_status' => 'draft');                  
$draft_posts = get_posts( $args );

foreach($draft_posts as $posts) {
$my_post = array(
      'ID'           => $posts->ID,
      'post_date'    => date('Y-m-d H:i:s', $time),
      'post_status'  => 'future');
$my_post->edit_date = true;
wp_update_post( $my_post );
$time += 5400;                                   // every 1.5 hr
}

As soon as I run this, all drafts are published instantly at same time, rather than an interval of 1.5 hr. Can anyone please tell where is the problem?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top