前言
来自MAC大佬的又一款非常美观又实用的新发布文章列表角标,每个新发布的文章都会自动添加,用来提醒用户这篇文章是今日新发布的,有利于用户交互。
图片展示
![图片[1]-子比主题美化-新发布文章列表角标(NEW) - 网络技术的交流与分享 - 资源站,技术站,资讯网](/wp-content/uploads/replace/89bdf20e4bf68d24cd74a3a762904829.png)
在主题目录 func.php
文件添加如下代码。
/*新文章发布角标*/
function add_zbfox_new_post_label($title, $id) {
if (!is_admin() && !is_single()) {
$post_time = get_the_time('U', $id);
if (time() - $post_time <= 24 * 60 * 60) {
$title .= ' <div class="zbfox_new_post_label">NEW</div>';
}
}
return $title;
}
add_filter('the_title', 'add_zbfox_new_post_label', 10, 2);
最新版CSS代码添加到子比主题后台设置->自定义代码->自定义CSS样式
/*新文章发布图标样式*/
.posts-item{
position: relative;
overflow: visible;
}
.zbfox_new_post_label{
position: absolute;
top: 15px;
right: 0;
padding: 5px 10px;
background: #4f15ff;
box-shadow: -1px 2px 4px rgba(0, 0, 0, 0.5);
/*url: huliku.com*/
color: #fff;
font-size: 13px;
font-weight: 900;
border-radius: 5px 0 0 5px;
}
.posts-item:hover .zbfox_new_post_label {
opacity: 0;
transition: opacity 0.5s ease;
}
.zbfox_new_post_label:before {
position: absolute;
content: " ";
display: block;
width: 7px;
height: 110%;
padding: 0 0 7px;
top: 0;
right: -7px;
background: inherit;
border-radius: 0 5px 5px 0;
}
.zbfox_new_post_label:after {
position: absolute;
content: " ";
display: block;
width: 5px;
height: 5px;
background: rgba(0, 0, 0, 0.35);
bottom: -3px;
right: -5px;
border-radius: 0 5px 5px 0;
}
查看更多心仪的内容 按Ctrl+D收藏我们
部分内容来自于网络 如有不妥联系站长删除
欢迎前来投稿文章
© 版权声明
THE END
暂无评论内容