custom post scheduler for drafts

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?

Related posts

1 comment

  1. You’re treating $my_post as an array, and then an object. Try moving ‘edit_date’ into the array.

    Also keep in mind that ‘post_date’ should be in your blog’s timezone. date will give the date-time in UTC timezone. See date_i18n() (codex: http://codex.wordpress.org/Function_Reference/date_i18n).

    From what I can see, everything else is corret.

Comments are closed.