文本是《WordPress美化(共17篇)》专题的第 14 篇。阅读本文前,建议先阅读前面的文章:
- 1.WordPress博客为文章内容页添加展开收缩功能
- 2.7b2教程-添加横幅广告条
- 3.WordPress日主题专业版UI美化RIPro9.0子主题
- 4.Zibll子比主题缩略图美化插件
- 5.7b2最新自定义角标_随心所欲改色
- 6.RiProV2美化-用代码实现彩色标签云
- 7.RIPro-V5主题添加标签云彩色代码
- 8.RIPro-V5主题单独添加首页logo而其它页面保持不变
- 9.RiPro-V5主题首页四格美化小工具教程
- 10.VAN主题V1.5版本|RIPRO_V5子主题
- 11.B2主题美化:纯代码实现文章列表封面显示文章内图片数量
- 12.B2Pro主题美化 文章头部信息/资源类文章美化
- 13.子比功能增强-发布文章自定义文章动态前缀申明(更新,适配移动端)
演示效果

首先找到b2主题或者子主题下面的/themes/b2child/Modules/Templates/Modules/posts.php搜索代码modules-title-box然后对应下面的代码添加
// $desc = in_array('desc',$post_meta);
$randomNumber = rand(1, 7);
//$desc = in_array('desc',$post_meta);
$html .= '<div class="modules-title-box" id="biaotibg'.$randomNumber.'">';

其次/b2child/Modules/Templates/Modules/Products.php搜索代码modules-title-box然后对应下面的代码添加
$randomNumber = rand(1, 7);
$html .= '<div class="shop-box-title"><div class="modules-title-box" id="biaotibg'.$randomNumber.'">';

第三步找到b2主题或者子主题下面的/Modules/Templates/Header.php的 <style>与.header-banner{之间添加下面代码
#biaotibg1 {
height: 39px;
background: url(https://www.laipang.com/wp-content/themes/b2child/pic/goods-title.png) no-repeat;
background-position: 0 0;
position: relative;
margin-left: -10px;
margin-right: 20px;
}
#biaotibg2 {
height: 39px;
background: url(https://www.laipang.com/wp-content/themes/b2child/pic/goods-title.png) no-repeat;
background-position: 0 -55px;
position: relative;
margin-left: -10px;
margin-right: 20px;
}
#biaotibg3 {
height: 39px;
background: url(https://www.laipang.com/wp-content/themes/b2child/pic/goods-title.png) no-repeat;
background-position: 0 -385px;
position: relative;
margin-left: -10px;
margin-right: 20px;
}
#biaotibg4 {
height: 39px;
background: url(https://www.laipang.com/wp-content/themes/b2child/pic/goods-title.png) no-repeat;
background-position: 0 -165px;
position: relative;
margin-left: -10px;
margin-right: 20px;
}
#biaotibg5 {
height: 39px;
background: url(https://www.laipang.com/wp-content/themes/b2child/pic/goods-title.png) no-repeat;
background-position: 0 -220px;
position: relative;
margin-left: -10px;
margin-right: 20px;
}
#biaotibg6 {
height: 39px;
background: url(https://www.laipang.com/wp-content/themes/b2child/pic/goods-title.png) no-repeat;
background-position: 0 -275px;
position: relative;
margin-left: -10px;
margin-right: 20px;
}
#biaotibg7 {
height: 39px;
background: url(https://www.laipang.com/wp-content/themes/b2child/pic/goods-title.png) no-repeat;
background-position: 0 -330px;
position: relative;
margin-left: -10px;
margin-right: 20px;
}
.modules-title-box .module-title {
padding-left: 45px;
padding-top: 8px;
}
最后一步
在子主题下functions.php加载刚刚修改的这些文件,如果子主题没有这三个文件,对应 从b2里面复制到子主题下面
require_once get_theme_file_path('/Modules/Templates/Header.php');
require_once get_stylesheet_directory() . '/Modules/Templates/Modules/Posts.php';
require_once get_stylesheet_directory() . '/Modules/Templates/Modules/Products.php';
您已阅读完《WordPress美化(共17篇)》专题的第 14 篇。请继续阅读该专题下面的文章: