详情
评论
问答

子比主题 – 文章更新时间提醒样式

子比主题 – 文章更新时间提醒样式-阿呆日记
子比主题 – 文章更新时间提醒样式
此内容为免费资源,请登录后查看
0
免费资源
图片[1]-子比主题 – 文章更新时间提醒样式-阿呆日记

教程

这个PHP代码放到:/wp-content/themes/zibll/functions.php或者func.php,代码如下,直接放里面即可!

//文章过期提示结束 
function article_time_update() {
    date_default_timezone_set('PRC');
    $newdate = time();
    $updated_date = get_the_modified_time('Y-m-d H:i:s');
    $updatetime = strtotime($updated_date);
    $custom_content = '';
    if ($newdate > $updatetime + 86400) {
        $custom_content = '<div class="article-update-tips"><p class="update-ts">文章最后更新时间:<span1>' . $updated_date . '</span1></p></div>';
    }
    echo $custom_content;
}
add_action('zib_posts_content_before', 'article_time_update');
//文章过期提示结束

放到后台自定义CSS

                .update-ts{
                    padding-top: 6px;
                    padding-bottom: 8px;
                }
                .article-update-tips {
                background: rgba(255, 188, 68, 0.38);
                color: #333;
                margin: 0 0px 20px;
                border-radius: 8px;
                position: relative;
                text-align: center;
                background-image: url(https://img.alicdn.com/imgextra/i1/2210123621994/O1CN017ZFVO81QbIjgNEl4Q_!!2210123621994.png);
                background-clip: padding-box;
                background-size: cover;
                background-repeat: no-repeat;
                background-attachment: scroll;
                background-position: 50% 50%;
                background-blend-mode: normal;
            }span1 {
                color: #f60;
                margin: 0 3px;
            }
© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容