AT互联|ripro添加自动随机文章阅读次数_
AT互联|ripro添加自动随机文章阅读次数_手机扫码预览

AT互联|ripro添加自动随机文章阅读次数_

660
免费 优惠信息:免费 暂无永久SVIP下载特权
  • 免费售前咨询
  • 登录下载更划算哦
  • 付费安装资源
  • 付费终身升级
  • QQ保障售后服务
  • 网站应急咨询顾问

ripro添加自动随机文章阅读次数

位置:riproinctheme-functions.php

搜索 post 文章阅读次数   找到以下代码

原本未修改的代码

/**
 * post 文章阅读次数
 */
function _post_views_record()
{
    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);
            }
        }
    }
}


function _get_post_views($before = \'\', $after = \'\')
{
    global $post;
    $post_ID = $post->ID;
    $views   = (int) get_post_meta($post_ID, \'views\', true);
    if ($views >= 1000) {
        $views = round($views / 1000, 2) . \'K\';
    }
    return $before . $views . $after;
}

 

将以下代码替换上面原本的代码即可

/**
 * post 文章阅读次数
 */
function _post_views_record()
{
    if (is_singular()) {
        global $post;
        $post_ID = $post->ID;
        if ($post_ID) {
            $post_views = (int) get_post_meta($post_ID, \'views\', true);
            
        $min = 128;
        $max = 863;
        //如果阅读量小于$min,则自动计算一个$min~$max的随机数作为阅读量
        if($post_views<$min){
            $post_views=rand($min,$max);
        }
            if (!update_post_meta($post_ID, \'views\', ($post_views + 1))) {
                add_post_meta($post_ID, \'views\', 1, true);
            }
        }
    }
}


function _get_post_views($before = \'\', $after = \'\')
{
    global $post;
    $post_ID = $post->ID;
    $views   = (int) get_post_meta($post_ID, \'views\', true);
    if ($views >= 1000) {
        $views = round($views / 1000, 2) . \'K\';
    }
    return $before . $views . $after;
}

 

AT互联|ripro添加自动随机文章阅读次数_-AT互联全栈开发服务商

打破行业潜规则-更多选择 更低价格 更快交付!
AT互联全栈开发服务商 » AT互联|ripro添加自动随机文章阅读次数_
欢迎您光顾,建议使用 QQ 登录
喜欢我嘛?喜欢就按“ctrl+D”收藏我吧!♡