无缝插入B2主题设置-圈子设置,前端广告效果跟发帖没啥区别,先看效果

- 支持开启或关闭广告功能
- 支持多条广告随机展示
- 支持广告最小间隔多少帖子、最大间隔多少帖子
- 支持自定义广告主名称、头像、标签
- 支持自定义广告标题、描述、链接、图片、视频、自定义HTML
- 支持自定义文本以及链接
同一个广告,如果同时设置了图片和视频,将优先显示视频,如果设置了自定义HTML,将优先显示自定义HTML内容!



下面来讲如何实现在B2主题圈子的帖子列表里随机插入广告
在子主题的functions.php文件中添加代码:
在style.css中添加代码:
/*圈子随机AD*/
.circle-topic-ad-item{
position: relative;
border-top:1px solid #efefef;
background-color: #fafafa
}
.topic-ad-box{
position: relative
}
.topic-ad-avatar-icon{
display: flex;
align-items: center;
justify-content: center;
width: 36px;
height: 36px;
background-color: #f0f0f0;
font-size: 18px;
color: #8590a6
}
.topic-ad-box .topic-avatar img.b2-radius{
width: 100%;
height: 100%;
object-fit: cover
}
.topic-ad-label{
display: inline-block;
background-color: #f0f0f0!important;
color: #8590a6!important;
border: none!important;
font-size: 11px;
padding: 1px 6px;
border-radius: 2px;
font-weight: normal;
line-height: 1.4;
margin-top: 2px
}
.topic-ad-sponsor-name{
display: block;
font-size: 15px;
color: #494B4D;
font-weight: 600;
line-height: 1.3
}
.topic-ad-content{
padding: 8px 20px 8px 68px
}
.topic-ad-link{
display: block;
color: inherit;
text-decoration: none
}
.topic-ad-link:hover{
color: inherit
}
.topic-ad-link h2{
margin-bottom: 8px
}
.topic-ad-link p{
color: #8590a6;
font-size: 14px;
line-height: 1.6;
margin-bottom: 8px
}
.topic-ad-image{
overflow: hidden;
margin-top: 8px;
max-width: 100%
}
.topic-ad-image img{
width: 100%;
height: auto;
display: block;
border-radius: 4px
}
.topic-ad-video{
overflow: hidden;
margin-top: 8px;
max-width: 100%
}
.topic-ad-video video{
width: 100%;
height: auto;
display: block;
border-radius: 4px;
background-color: #000
}
.topic-ad-footer{
padding: 15px 20px 20px;
display: flex;
justify-content: space-between;
align-items: center
}
.topic-ad-date{
font-size: 12px;
color: #c0c0c0
}
.topic-ad-go-button{
display: inline-block;
padding: 4px 16px;
border-radius: 3px;
font-size: 13px;
color: #fff;
background-color: #8590a6;
text-decoration: none;
transition: background-color .2s
}
.topic-ad-go-button:hover{
background-color: #727d8c;
color: #fff
}
.topic-ad-custom-html{
padding: 0px;
position: relative
}
.topic-ad-custom-html img{
max-width: 100%;
height: auto
}
@media screen and (max-width:768px){
.circle-topic-ad-item{
padding:0
}
.topic-ad-content{
padding: 6px 16px
}
.topic-ad-footer{
padding: 15px 16px 16px
}
.topic-ad-avatar-icon{
width: 36px;
height: 36px
}
.topic-ad-sponsor-name{
font-size: 14px
}
.topic-ad-label{
font-size: 10px
}
.topic-ad-box .topic-avatar img.b2-radius{
width: 100%;
height: 100%;
object-fit: cover
}
.topic-ad-custom-html{
padding: 16px
}
}
/*end*/
然后将circle-topic-list.php文件上传到子主题的TempParts/circle文件夹中即可!
本文标题:在B2主题圈子的帖子列表里随机插入广告,支持多种自定义选项
本文链接:https://tcbdb.com/578.html
声明:本站所有文章,如无特殊说明或标注,均为本站原创或用户投稿发布。任何个人或组织,在未征得本站或作者同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。










