它实际上没有API,因为从使用角度来看,它非常简单。
如果数据传递给wp_insert_post() 有publish 或future 中的值post_status 字段和日期,然后将其插入数据库中,并带有该日期和future 在里面post_status. 实际上,它已经被视为已安排好了。
然而,需要发生一些事情才能使该帖子在该日期发布,因此这又启动了几段代码:
何时wp_insert_post() 完成它调用wp_transition_post_status().
执行多个挂钩,包括"{$new_status}_{$post->post_type}" 它展开为future_post.
当职位类型由注册人注册时register_post_type() 它添加了_future_post_hook() 功能到\'future_\' . $post_type 钩子并执行该函数创建单个WP-Cron 发布日期的时间表、数据中的发布ID和publish_future_post.该计划名称具有check_and_publish_future_post() 连接到它的函数,即运行时检查该ID的post是否已计划并已启动,如果是,则将其状态翻转为published 使用wp_publish_post().因此,创建计划帖子的最简单方法就是遵循本机机制并使用wp_insert_post(), 在传递未来日期时。