// by itbulu.com 整理。
function wpxss_update_post_timestamp_on_view() {
if (is_single()) { // only update for single post pages
$post_id = get_the_ID();
$current_time = current_time('mysql');
$post_data = array(
'ID' => $post_id,
'post_modified' => $current_time,
'post_modified_gmt' => get_gmt_from_date($current_time),
);
wp_update_post($post_data);
}
}
add_action('the_post', 'wpxss_update_post_timestamp_on_view');但是这个也有一个问题,如果文章多且访客多,势必会给服务器和网站带来很大的压力的。