最近因为需要大量整理教程想用一下定时发布功能,但是在测试过程中发现单独设置发布正常,如果批量更改时间就不行,提示定时发布失败,在网上查了一些资料,测试了一下,发现以下两种方法可以解决,供大家参考,文章来源第三方网站。
第一种方法:
将代码添加到当前主题 – functions.php 中:(推荐,本站使用的就是这个)
if (!function_exists( 'add_action' ) ) {
header( 'Status 403 Forbidden' );
header( 'HTTP/1.0 403 Forbidden' );
header( 'HTTP/1.1 403 Forbidden' );
exit();
}
function wpms_log() {
echo"n";
}
add_action( 'wp_head', 'wpms_log' );
add_action( 'wp_footer', 'wpms_log' );
define( 'WPMS_DELAY', 5 );
define( 'WPMS_OPTION', 'wp_missed_schedule' );
function wpms_replace() {
delete_option(WPMS_OPTION);
}
register_deactivation_hook(__FILE__,'wpms_replace');
function wpms_init() {
remove_action('publish_future_post','check_and_publish_future_post');
$last=get_option(WPMS_OPTION,false);
if (($last!==false)&&($last>(time()-(WPMS_DELAY*60))))return;
update_option(WPMS_OPTION,time());
global$wpdb;
$scheduledIDs=$wpdb->get_col("SELECT`ID`FROM`{$wpdb->posts}`"."WHERE("."((`post_date`>0)&&(`post_date`<=CURRENT_TIMESTAMP()))OR"."((`post_date_gmt`>0)&&(`post_date_gmt`<=UTC_TIMESTAMP()))".")AND`post_status`='future'LIMIT 0,5");
if (!count($scheduledIDs))return;
foreach($scheduledIDs as$scheduledID) {
if (!$scheduledID)continue;
wp_publish_post($scheduledID);
}
}
add_action( 'init', 'wpms_init', 0 );
第二种方法:
推荐两款解决定时发布失败的插件:WP Missed Schedule Posts 和 MY Missed Schedule;
WP Missed Schedule官方下载地址:http://wordpress.org/extend/plugins/wp-missed-schedule/
MY Missed Schedule官方下载地址:https://cn.wordpress.org/plugins/my-missed-schedule/advanced/
不管使用哪个办法,定时设置之后或者原来有大量定时发布失败的文章,需要在使用后等待五分钟左右,如果还是不行或者有更好的解决办法可以圈子留言交流。
本站使用静态缓存,登录后获取实时最新资源下载。推荐使用QQ登录,会自动完成注册。
如遇夸克/网盘资源失效,请发帖反馈。站长会积极补链,同时在您的帖子下方评论告知。
如遇夸克/网盘资源失效,请发帖反馈。站长会积极补链,同时在您的帖子下方评论告知。
© 版权声明
资源来源于互联网,供学习交流。如涉侵权,请邮件联系,将予七日内处理。
请在下载后24小时内删除,切勿商用。使用者需自行承担相应法律责任,发布者概不负责。
请在下载后24小时内删除,切勿商用。使用者需自行承担相应法律责任,发布者概不负责。
THE END









![[端游单机] 原神- (V5.3+V5.0+V4.7+V4.6+V4.5+V4.01)单机(本地)剧情至尊整合版-七玩网](http://static.527wan.top/wp-content/uploads/2025/02/b5767abdfc20250222194201.png)



暂无评论内容