添加延迟到wordpress后视图

时间:2015-08-01 19:47:18

标签: php wordpress delay

嘿伙计们,我有一个wordpress主题,我使用下面的代码进行页面/帖子查看(进入function.php)

function getPostViews($postID){
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
return;
}
return $count;
}

// function to count views.
function setPostViews($postID) {
$count_key = 'post_views_count';
$count = get_post_meta($postID, $count_key, true);
if($count==''){
$count = 0;
delete_post_meta($postID, $count_key);
add_post_meta($postID, $count_key, '0');
}else{
$count ++;
update_post_meta($postID, $count_key, $count);
}
}

我想添加1小时的延迟来更新帖子视图,例如,如果帖子视图为0,则不要将其更改1小时但保存1小时后将其更新为上次保存的视图并重复这份工作 我该怎么做?帮帮我们:

0 个答案:

没有答案