欢迎光临范耀祖的个人博客,关注生活,福利,以及网络营销心得!

wordpress定时发送失败的解决方法

生活随记 fancy 2℃

wordpress定时发送失败的解决方法

目前大家都在用的解决办法有以下两种:
一、修改 cron.php文件的默认发布的时间
用 notedpad++ 或者相关工具打开 wp-includes 目录下的 cron.php 文件并进行编辑。

在cron.php 文件中搜索找到“timeout”,将该代码后面的数值0.01修改为10.00即可。数值也不一定是10,只要比0.01大就可以。大概在923行,\’timeout\’ => 0.01改为\’timeout\’ => 10。

二、通过安装插件解决
推荐两个插件WP Missed Schedule post或者 easy-schedule-post

安装的是WP missed Schedule post这个插件,插件安装好启用之后先前定时发布失败的文章会立马发布完成。

经过实测,安装插件的方法可行。

三,将代码添加到当前主题的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 );

转载请注明:范耀祖 » wordpress定时发送失败的解决方法

喜欢 (0)