WordPress
WordPress
经常有用户说定时发布文章是提示失败,造成失败原因不太清楚,应该是主机慢有关吧,我自己从没遇到过,这里记录一下解决办法,供大家参考。
推荐两款解决定时发布失败的插件:WP Missed Schedule Posts和MY Missed Schedule
WP Missed Schedule Posts
MY Missed Schedule
也可以用下面的代码,代码应该是提取自老版本的WP Missed Schedule Posts插件,将代码添加到当前主题 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 );
代码添加后,定时发表文章还是会提示失败,但过二、三分钟后,会正常发布的。
至于哪个方法适合你,只能自己试了。
本文方法源自网络

下载说明:
1. 本站所有资源来源于网络和用户上传,如有侵权请联系站长
2. 本站分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 不得使用于非法商业用途,商用请支持正版!不得违反国家法律,否则后果自负!
6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需!
本站的资源均来自于互联网,仅为资源共享、学习参考之目的,其版权均归原作者及其网站所有,如有侵权请留言联系:admin,转转请注明出处:http://zhanmr.com/3636.htm