广告投放

WordPress 定时发布失败解决办法(附无插件实现方法)

目录

    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 );

    代码添加后,定时发表文章还是会提示失败,但过二、三分钟后,会正常发布的。

    至于哪个方法适合你,只能自己试了。

    声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

    给TA打赏
    共{{data.count}}人
    人已打赏
    广告位招租919838898
    0 条回复 A文章作者 M管理员
      暂无讨论,说说你的看法吧
    个人中心
    购物车
    优惠劵
    今日签到
    有新私信 私信列表
    搜索