教程开始
打开ripro-v2/inc/template-tags.php文件
使用全局搜索“阅读”
将以下代码覆盖到图片位置即可
/** * 添加文章阅读数量 * @Author Dadong2g * @DateTime 2021-01-25T20:13:59+0800 function add_post_views($post_id = null){ if (empty($post_id)) { global $post; $post_id = $post- $this_num = (int)(rand(30,50) + (int)get_post_meta($post_id,'views',true)); $new_num = $this_num+1; if ($new_num 0 ) { $new_num = 1; return update_post_meta( $post_id, 'views', $new_num );
注释:rand(30,50)中30位置是每次点击最少增加的阅读量,50位置是每次点击最多增加的阅读量