1、安装插件 WP-PostViewsWP-Postviews 安装非常简单,只要上传和激活即可。然后到 WP 后台 > 设置 > Postviews 配置在使用的地方添加wordpress调用标签<?php if(function_exists(‘the_views’)) { the_views(); } ?>
2、用代码实现浏览统计功能用Dreamweaver打开functions.php,在functions.php中添加以下代码:/* 访问计数 */function record_visitors(){if (is_singular()){global $post;$post_ID = $post->ID;if($post_ID){$post_views = (int)get_post_meta($post_ID, ’views’, true);if(!update_post_meta($post_ID, ’views’, ($post_views+1))){add_post_meta($post_ID, ’views’, 1, true);}}}}add_action(‘wp_head’, ’record_visitors’);/// 函数名称:post_views /// 函数作用:取得文章的阅读次数function post_views($before = ’(点击 ‘, $after = ’ 次)’, $echo = 1){global $post;$post_ID = $post->ID;$views = (int)get_post_meta($post_ID, ’views’, true);if ($echo) echo $before, number_format($views), $after;else return $views;}在需要显示的地方调用WP标签<?php post_views(‘ ’, ’ 次‘); ?>