【问题标题】:WP Future Posts are not being publishedWP Future Posts 未发布
【发布时间】:2014-04-11 09:46:33
【问题描述】:
$date = date("Y-m-d H:i:s");
$date = strtotime("+60 minutes");
$date = date("Y-m-d H:i:s", $date);
$postId = wp_insert_post(array(
    'post_author' => 1,
    'post_category' => $kategori,
    'post_content' => $aciklama,
    'post_status' => 'future',
    'post_date' => $date,
    'post_date_gmt' =>$date,
    'post_title' => $adi,
    'post_excerpt' => '',
    'post_type' => 'post',
    'tags_input' => $etiketler
));

上面的代码我已经写好了。它将帖子插入数据库,我在文章列表中看到了该帖子。但它不会在时间到来时发布(现在 + 60 分钟)。我错过了什么?到时候我应该写点什么让它出版吗?

【问题讨论】:

  • 设置 -> 常规页面中的时区是否正确?
  • 是的,这似乎是正确的。还有另一个机器人按预期工作。不幸的是,我看不到它的代码。

标签: php wordpress scheduled-tasks


【解决方案1】:

从 WordPress 功能中试试这个日期,

$cur_date = current_time('mysql');
$date = date("Y-m-d H:i:s", strtotime($cur_date) . "+60 minutes");

可能对你有帮助。

【讨论】:

  • 这行得通。谢谢。我一定在日期上犯了一些错误。 :)
猜你喜欢
  • 1970-01-01
  • 2020-08-14
  • 2018-08-13
  • 2019-06-16
  • 1970-01-01
  • 1970-01-01
  • 2017-11-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多