Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have about 60 posts queued and ready to post on specific dates, but I forgot to set the post time. I really don't want a bunch of posts posting at 3AM, so I need to change the times on all these posts.

Is there any way to do this, programmatically or with a plugin?

share|improve this question

1 Answer 1

If you have the id of the posts, you can use wp_update_post and change the post_date.

foreach ($postId as $id) {
  // random hour and time. You can also manually set these.
  $h = rand(1, 23);
  $i = rand(0, 59); 

  $newDate = array(
    'ID' => $id,
    'post_date' => "2013-12-19 $h:$i:59" // [ Y-m-d H:i:s ]
  );

  wp_update_post($newDate);
}
share|improve this answer
    
So, I just stick this in a new php file, or where should I stick this? Cheers –  user2274612 Dec 19 '13 at 17:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.