• 孙锡源
    管理员

    装这个插件:https://litepress.cn/plugins/wp-crontrol

    看看设置的定时任务执行时间是多少。

  • enterdawn
    参与者

    看看系统时区对不对,也许系统时间是格林尼治时间。

  • 孙锡源
    管理员

    添加以下代码尝试在发布文章时重新指定触发时间戳:

    add_action( 'save_post', function ( int $post_ID, WP_Post $post ) {
        if ( 'future' !== $post->post_status ) {
            return;
        }
    
        wp_clear_scheduled_hook( 'publish_future_post', array( $post_ID ) );
        wp_schedule_single_event( strtotime( $post->post_date )/* + 28800 */, 'publish_future_post', array( $post_ID ) );
    }, 9999, 2 );

    如果依然早8小时发布的话,就把上面代码中的注释去掉,这样就会在文章发布时将任务向后偏移8小时。

  • 不凡
    参与者

    楼主解决了吗?

  • 正在查看 4 条回复
    • 哎呀,回复话题必需登录。

    加入 LitePress 论坛 ,参与知识分享与交流
    登录 注册 进行评论
    立即加入