$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>Any way to create scheduled post programatically?|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Any way to create scheduled post programatically?

matteradmin8PV0评论

I'm searching through the web for any solutions that will allow me to create a post programatically with post status : Future (Scheduled Post).

I'm reading through wp_schedule_event WordPress function for creating cron jobs.

Thanks in advance.

I'm searching through the web for any solutions that will allow me to create a post programatically with post status : Future (Scheduled Post).

I'm reading through wp_schedule_event WordPress function for creating cron jobs.

Thanks in advance.

Share Improve this question asked Dec 27, 2014 at 6:22 Ravi SoniRavi Soni 6971 gold badge7 silver badges17 bronze badges 1
  • 1 I'm not sure about your context, but we dealt with scheduled posts a few days ago, and @birgire did an excellent job done. Have a look if it may answer you. :) – Mayeenul Islam Commented Dec 27, 2014 at 8:01
Add a comment  | 

1 Answer 1

Reset to default 7

I found my answer while searching over other stackoverflow answers below is the code what I've added.

$postdate = date('Y-m-d H:i:s',strtotime('+20 minutes'));
$postdate_gmt = gmdate('Y-m-d H:i:s',strtotime($postdate));

$post = array(
    'post_date_gmt'  => $postdate_gmt,
    'post_date'  => $postdate,
    'edit_date' => 'true'
);
Post a comment

comment list (0)

  1. No comments so far