我正在使用下面的代码,但不工作。请告诉我是否有其他方法或我在哪里犯错?
//cron work
function isa_add_every_minutes( $schedules ) {
$schedules[\'every_minutes\'] = array(
\'interval\' => 60,
\'display\' => __( \'Every 1 Minutes\', \'textdomain\' )
);
return $schedules;
}
add_filter( \'cron_schedules\', \'isa_add_every_minutes\' );
// Add function to register event to WordPress init
add_action( \'init\', \'register_event\');
// Function which will register the event
function register_event() {
// Make sure this event hasn\'t been scheduled
if( !wp_next_scheduled( \'post_status_change\' ) ) {
// Schedule the event
wp_schedule_event( time(), \'every_minutes\', \'post_status_change\' );
}
}
add_action( \'post_status_change\', \'post_status_change_all\' );
// This function will run once the \'delete_post_revisions\' is called
function post_status_change_all() {
global $wpdb;
$daystogo = "5";
$sql = "UPDATE wp_posts SET post_status = \'draft\' WHERE post_type = \'post\' AND DATEDIFF(NOW(), post_date) > \'$daystogo\')";
echo $sql;
$wpdb->query( $sql );
}
谢谢。。