0

I am working on WordPress Plugin and want to add scheduled post in my plugin. Can anyone share a sample code for how to do this?

I am using wp_insert_post() function for add post, I guess I have to modify parameters in this function. 'post_status' => 'future'

I am not sure how to set date and time when the post get published!

Amit Verma
  • 8,660
  • 8
  • 35
  • 40
Capripio
  • 474
  • 11
  • 21

1 Answers1

1

Both functions wp_insert_post and wp_update_post accepts an array of posts.

And among the parameters, you can set the value of post_date and post_date_gmt.

Jaime Gris
  • 1,136
  • 6
  • 11
  • 1
    Yep. I believe it does work. Make sure that you set both the `post_date` and `post_date_gmt`. By the way, the format should be `Y-m-d H:i:s` (for example, 2013-06-13 00:00:00) – Jaime Gris Jun 13 '13 at 14:53
  • One more question, Did I need to set both? or Just set any one of theme like post_date OR post_date_gmt? – Capripio Jun 13 '13 at 14:56
  • Yes, both. Honestly, I don't know the implications for posting only one date, but just to be safe. – Jaime Gris Jun 13 '13 at 14:57