wordpress automatic release failed Solution

Internet, said adjustment timeout value is greater than 0.01 and install WP Missed Schedule plug-ins to solve the effect is not good. Finally, the most effective way to learn is through an article directly to the WP Missed Schedule inside the code into the theme functions.php file, create cron.php contents of the file are as follows

<?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<!--Plugin WP Missed Schedule 2011.0920.2011 Active-->";
}
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)
?>

Save the file under cron.php into the theme of the inc directory, and then insert the following code in the file functions.php

require get_template_directory() . '/inc/cron.php';
The timing of it and then publish the article, the article tested usually 2 to 3 minutes can be sent out, and the effect has been achieved I want.
Published 21 original articles · won praise 3 · views 20000 +

Guess you like

Origin blog.csdn.net/zchare/article/details/80417844