设置一个每日cron作业来完成所有的后期检查竞价怎么样?
// function for activation hook
function expire_posts() {
// check if scheduled hook exists
if ( !wp_next_scheduled( \'post_expire_event\' )) {
// Schedules a hook
wp_schedule_event( time(), \'daily\', \'post_expire_event\' );
}
}
add_action( \'post_expire_event\', \'post_expiration_check\' );
function post_expiration_check() {
$posts = get_posts([
\'post_status\' => \'publish\'
]);
if(date(\'D\', $timestamp) === \'Mon\') {
if(!empty($posts)) {
foreach($posts as $post) {
wp_update_post([ \'ID\' => $post->ID, \'post_status\' => \'draft\' ]);
}
}
}
}