不在核心。您可以使用post meta在页面加载上存储此信息。如果启用了缓存插件,您可能希望通过AJAX调用增加命中计数器,否则您可以直接将其添加到单缓存中。php和页面。php模板:
//Add to functions.php
function get_hits(){
global $post;
$hits = get_post_meta($post->ID, \'_hit-counter\', true);
return $hits;
}
function update_hits($count){
global $post;
$count = $count ? $count : 0;
$hits = update_post_meta($post->ID, \'_hit-counter\', $count++);
return $hits;
}
//Usage within the loop
update_hits(get_hits());