0

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?

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);
}
| 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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