WordPress(RiPro主题)文章页怎么把时间精确到秒(已解决)

WordPress(RiPro主题)文章页发布后显示为“xx秒前”,为了符合百度优化规则需要改成 (年-月-日 时:分:秒)格式。

解决办法

1.找到WordPress/wp-content/themes/ripro/inc目录,修改theme-functions.php文件

WordPress(RiPro主题)文章页怎么把时间精确到秒(已解决)

把以下代码(大约在2062行):

function _timeago($time) {
    $time       = strtotime($time);
    $difference = time() - $time;
    if (!_cao('post_is_timeago', '1')) {
        return date('Y-m-d', $time);
    }
    switch ($difference) {
    case $difference <= '1': $msg = '刚刚'; break; case $difference > '1' && $difference <= '60': $msg = '' . date('Y-m-d H:i:s', $time) . ''; break; case $difference > '60' && $difference <= '3600': $msg = '' . date('Y-m-d H:i:s', $time) . ''; break; case $difference > '3600' && $difference <= '86400': $msg = '' . date('Y-m-d H:i:s', $time) . ''; break; case $difference > '86400' && $difference <= '2592000': $msg = '' . date('Y-m-d H:i:s', $time) . ''; break; case $difference > '2592000':
        $msg = '' . date('Y-m-d', $time) . '';
        break;
    }
    return $msg;
}

更改为:

function _timeago($time) {
    $time       = strtotime($time);
    $difference = time() - $time;
    if (!_cao('post_is_timeago', '1')) {
        return date('Y-m-d', $time);
    }
    switch ($difference) {
    case $difference >= '1':
        $msg = '' . date('Y-m-d H:i:s', $time) . '';
        break;
    }
    return $msg;
}

最后在刷新文章页,显示的就是时间精确到秒的2021-04-08 11:11:19格式了。

版权声明:原创文章,作者(大鹏),如若转载,请注明出处。WordPress(RiPro主题)文章页怎么把时间精确到秒(已解决):https://www.31seo.com/639.html

发表评论

登录后才能评论