我正在使用这个功能,它似乎工作得很好,但我想知道我是否必须使用wp_reset_postdata
之后endwhile
?
function evecal_task_function() {
$args=array(
\'posts_per_page\' => -1,
\'post_type\' => \'events\'
);
$now = time();
$the_query = new WP_Query( $args );
if ( $the_query->have_posts() ) :
while ( $the_query->have_posts() ) : $the_query->the_post();
$fxdate = strtotime(get_field(\'fl_date\',false,false));$datediff = $now - $fxdate;
if ( $datediff > 1) {update_field(\'fl_expire\', \'1\', get_the_ID());}
endwhile;
endif;
}