WordPress系统7b2主题首页栏目文章标题美化。这篇文章介绍了如何美化7b2首页文章标题,包括在相关代码中添加模块标题框、修改CSS样式以设置背景和边距,以及在子主题的functions.php中加载这些文件,以实现更美观的标题效果。

首先找到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://oss.dzcrv.com/1/goods-title.png) no-repeat;
background-position: 0 0;
position: relative;
margin-left: -10px;
margin-right: 20px;
}
#biaotibg2 {
height: 39px;
background: url(https://oss.dzcrv.com/1/goods-title.png) no-repeat;
background-position: 0 -55px;
position: relative;
margin-left: -10px;
margin-right: 20px;
}
#biaotibg3 {
height: 39px;
background: url(https://oss.dzcrv.com/1/goods-title.png) no-repeat;
background-position: 0 -385px;
position: relative;
margin-left: -10px;
margin-right: 20px;
}
#biaotibg4 {
height: 39px;
background: url(https://oss.dzcrv.com/1/goods-title.png) no-repeat;
background-position: 0 -165px;
position: relative;
margin-left: -10px;
margin-right: 20px;
}
#biaotibg5 {
height: 39px;
background: url(https://oss.dzcrv.com/1/goods-title.png) no-repeat;
background-position: 0 -220px;
position: relative;
margin-left: -10px;
margin-right: 20px;
}
#biaotibg6 {
height: 39px;
background: url(https://oss.dzcrv.com/1/goods-title.png) no-repeat;
background-position: 0 -275px;
position: relative;
margin-left: -10px;
margin-right: 20px;
}
#biaotibg7 {
height: 39px;
background: url(https://oss.dzcrv.com/1/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';