演示:https://www.okmg.cn/collection
第一步
把下载的taxonomy.php文件 上传到主题根目录
把下载的collections.php文件 上传到pages中
在以下代码添加到functions.php中
//专题功能
$labels = array(
'name' => '专题',
'singular_name' => 'special',
'search_items' => '搜索' ,
'popular_items' => '热门' ,
'all_items' => '所有' ,
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => '编辑' ,
'update_item' => '更新' ,
'add_new_item' => '添加' ,
'new_item_name' => '专题名称',
'separate_items_with_commas' => '按逗号分开' ,
'add_or_remove_items' => '添加或删除',
'choose_from_most_used' => '从经常使用的类型中选择',
'menu_name' => '专题',
);
register_taxonomy(
'special',
array('post'),
array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'special' ),
)
);
function get_post_thumbnail_url($post_id){
$post_id = ( null === $post_id ) ? get_the_ID() : $post_id;
$post=get_post($post_id);
if( has_post_thumbnail() ){ //如果有特色缩略图,则输出缩略图地址
$thumbnail_src = wp_get_attachment_image_src(get_post_thumbnail_id($post_id),'full');
$post_thumbnail_src = $thumbnail_src [0];
} else {
$post_thumbnail_src = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=['"]([^'"]+)['"].*>/i', $post->post_content, $matches);
if(!empty($matches[1][0])){
$post_thumbnail_src = $matches[1][0]; //获取该图片 src
}else{
$post_thumbnail_src = '';
}
}
return $post_thumbnail_src;
}
将以下css添加到样式文件中 日主题添加到diy.css
/*zhuanti start*/
.zt-wrap .zt-top {
padding-top: 1px;
background: #fafafa;
position: relative;
z-index: 20;
}
.zt-wrap .content {
display: block;
}
.zt-wrap .zt-menu {
padding: 28px 0 0;
border-bottom: 1px solid #f3f3f3;
margin-bottom: 30px;
text-align: center;
}
.zt-wrap .zt-menu a {
display: inline-block;
font-size: 18px;
font-weight: bold;
color: #666;
line-height: 25px;
padding-bottom: 18px;
border-bottom: 5px solid transparent;
margin: 0 25px;
}
.zt-wrap .zt-menu a.current {
color: #ff5c00;
border-bottom-color: #ff5c00;
}
.zt-wrap .items {
display: box;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
justify-content: space-between;
justify-content: flex-start;
flex-wrap: wrap;
margin: 0 -17px;
}
.zt-wrap .items .item {
width: 100%;
margin-bottom: 20px;
padding: 0 17px;
box-sizing: border-box;
}
.zt-wrap .items .item a {
border: 1px solid #eaeaea;
}
.zt-item .item-thumb {
position: relative;
}
.zt-item .item-thumb:before {
content: '';
display: block;
left: 0;
top: 0;
right: 0;
bottom: 0;
position: absolute;
background: rgba(0,0,0,0.2);
transition: all .2s;
z-index: 10;
}
.zt-item .item-thumb .thumb {
padding-top: 49.18918919%;
border-radius: 3px 3px 0 0;
}
.zt-item .item-thumb h5 {
position: absolute;
left: 0;
right: 0;
bottom: 20px;
line-height: 30px;
height: 30px;
overflow: hidden;
font-size: 14px;
font-weight: normal;
margin: 0;
color: #fff;
z-index: 10;
}
.zt-item .item-thumb h5 .l {
float: left;
}
.zt-item .item-thumb h5 span {
padding: 0 15px;
}
.zt-item .item-thumb h5 .r {
float: right;
}
.zt-item .item-thumb h5 span {
padding: 0 15px;
}
.zt-item .item-thumb:after {
content: '';
display: block;
position: absolute;
left: 0;
right: 0;
bottom: 0;
height: 20px;
background-image: -webkit-linear-gradient(top, rgba(255,255,255,0.7) 0, #fff 100%);
background-image: -o-linear-gradient(top, rgba(255,255,255,0.7) 0, #fff 100%);
background-image: linear-gradient(to bottom, rgba(255,255,255,0.7) 0, #fff 100%);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#b3ffffff', endColorstr='#ffffffff', GradientType=0);
z-index: 10;
}
.zt-item h2 {
line-height: 1;
font-size: 18px;
margin-bottom: 6px;
margin-top: 0;
height: 1.2em;
overflow: hidden;
color: #525252;
}
.zt-item h2:before {
content: '';
display: inline-block;
width: 4px;
height: 18px;
vertical-align: middle;
margin-right: 11px;
background: #ff5c00;
margin-top: -3px;
}
.zt-item h4 {
margin: 0 15px 15px;
font-size: 14px;
line-height: 1.5em;
height: 1.5em;
font-weight: normal;
overflow: hidden;
color: #525252;
}
.zt-item .entry {
margin: 0 15px 18px;
font-size: 14px;
line-height: 27px;
height: 54px;
overflow: hidden;
letter-spacing: .2px;
}
.zt-item a .entry {
color: #999;
}
.zt-item .btns {
text-align: center;
margin: 0 0 22px;
}
.thumb {
display: block;
width: 100%;
height: 0;
padding-top: 66.7%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-color: transparent;
position: relative;
overflow: hidden;
transition: all .2s;
}
.zt-item .btns .btn {
display: inline-block;
padding: 2px 1em;
font-size: 13px;
line-height: 22px;
border: 1px solid #eaeaea;
cursor: pointer;
letter-spacing: 1px;
}
.zt-item a {
display: block;
border-top-color: transparent;
color: #555;
border-radius: 3px;
overflow: hidden;
background: #fff;
transition: all .2s;
}
.zt-item a:hover .btns .btn {
border-color: #ff5c00;
background: #ff5c00;
color: #fff;
}
.zt-item a:hover {
box-shadow: 0 0 20px #eaeaea;
}
.zt-singular-header {
position: relative;
}
.zt-singular-header .bg {
height: 70%;
max-height: 400px;
position: absolute;
left: 0;
top: 0;
right: 0;
background-size: 4000%;
background-repeat: no-repeat;
background-position: center;
overflow: hidden;
}
.zt-singular-header .bg::before {
content: '';
display: block;
width: 100%;
height: 100%;
position: absolute;
left: 0;
top: 0;
background: inherit;
filter: blur(10px);
}
.zt-singular-header .bg::after {
content: '';
display: block;
position: absolute;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 30%;
background-image: linear-gradient(180deg, rgba(255,255,255,0.6) 1%, #FFFFFF 38%);
}
.zt-singular-header .breadcrumb {
font-size: 13px;
color: #fff;
margin-bottom: 17px;
}
.zt-singular-header .breadcrumb li {
display: inline;
}
.zt-singular-header .breadcrumb a {
color: #fff;
}
.zt-singular-header .breadcrumb li:after {
content: ' >';
}
.zt-singular-header .block {
position: relative;
}
.zt-singular-header .block::before {
content: '';
display: block;
width: 100%;
height: 50%;
position: absolute;
left: 0;
right: 0;
bottom: 0;
box-shadow: 0 25px 50px 0 rgba(237,237,237,0.5);
background: #fff;
}
.zt-singular-header .block-content {
background: #fff;
padding: 20px 20px 30px;
position: relative;
}
.zt-singular-header .item-thumb {
margin-bottom: 30px;
}
.zt-singular-header .item-thumb .thumb {
padding-top: 55%;
}
.zt-singular-header .block-main {
flex-grow: 1;
}
.zt-singular-header h2 {
font-size: 28px;
color: #333;
margin-bottom: 14px;
}
.zt-singular-header h4 {
font-size: 16px;
color: #888;
font-weight: normal;
margin: 0 -10px 20px;
padding-bottom: 10px;
border-bottom: 1px solid #f3f3f3;
}
.zt-singular-header p {
font-size: 13px;
color: #888;
line-height: 1.8;
margin-bottom: 20px;
}
.zt-singular-header h4 .item {
display: inline-block;
padding: 0 10px;
position: relative;
line-height: 40px;
}
.zt-singular-header h4 .item strong {
font-size: 16px;
color: #ff5c00;
font-family: Impact;
margin-right: 10px;
}
.tax-special .term-bar{
display: none;
}
.tax-special .site-content{
padding: 0px;
}
.zt-singular-content .main {
padding: 0 46px 0 0;
}
.section-title {
font-size: 20px;
color: #262626;
line-height: 28px;
padding-bottom: 15px;
border-bottom: 1px solid #f2f2f2;
position: relative;
font-weight: bold;
margin-bottom: 20px;
}
.zt-singular-content .section-title {
margin-bottom: 40px;
}
.flex {
display: box;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
justify-content: space-between;
}
.list-item-default {
justify-content: flex-start;
margin-bottom: 40px;
flex-direction: row-reverse;
}
.list-item-default {
margin-bottom: 55px;
flex-wrap: nowrap;
flex-direction: row;
}
.list-item-default .item-thumb {
width: 33.3333%;
flex-shrink: 0;
margin: 0 0 0 15px;
}
.list-item-default .item-thumb a {
border-radius: 3px;
}
.list-item-default .item-thumb .thumb {
padding-top: 63.6363%;
border-radius: 3px;
background-position: left;
}
.h-scale img, .h-scale .thumb {
transition: all .2s;
}
.list-item-default .item-content {
flex-grow: 1;
text-align: left;
}
.list-item-zt .zt-title {
display: flex;
flex-direction: column-reverse;
}
.list-item-zt .zt-title .item {
display: block;
font-style: normal;
}
.list-item-zt .zt-title .item {
display: inline;
}
.list-item-default .title .tag {
font-size: 12px;
font-weight: normal;
display: inline-block;
border: 1px solid #ff5c00;
color: #ff5c00;
padding: 0 3px;
border-radius: 2px;
vertical-align: text-bottom;
line-height: 20px;
margin-right: 5px;
}
.list-item-zt .zt-title .item {
display: block;
font-style: normal;
}
.list-item-default p {
font-size: 14px;
color: #888;
line-height: 24px;
height: 48px;
overflow: hidden;
margin-bottom: 14px;
display: none;
max-width: 615px;
}
.list-item-default h4 {
font-size: 12px;
font-weight: normal;
color: #a7a7a7;
line-height: 23px;
height: 23px;
overflow: hidden;
}
.list-item-default h4 i {
font-style: normal;
margin-right: 15px;
}
.zt-singular-header .container{
padding-top: 30px;
}
.zt-singular-header .container {
padding-top: 40px;
padding-bottom: 54px;
overflow: visible;
}
.zt-singular-content .back {
margin-bottom: 60px;
}
.zt-singular-content .back .btn {
font-size: 16px;
display: block;
line-height: 3.125;
}
.btn-orange {
background: #ff5c00;
color: #fff;
}
@media (min-width: 768px){
.zt-wrap .zt-menu {
padding: 48px 0 0;
margin-bottom: 50px;
}
.zt-wrap .items .item {
width: 33.3333%;
margin-bottom: 40px;
}
.zt-item {
margin-bottom: 30px;
background: #fff;
}
.zt-item h2 {
height: 1.5em;
font-size: 22px;
padding-top: 5px;
}
.zt-item h4 {
font-size: 16px;
}
.zt-item .btns .btn {
font-size: 14px;
line-height: 32px;
}
.zt-singular-header .bg {
background-size: 300%;
}
.zt-singular-header .bg::before {
filter: blur(50px);
}
.zt-singular-header .block-content {
display: box;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
justify-content: space-between;
padding: 40px;
}
.zt-singular-header .block-thumb {
width: 370px;
}
.zt-singular-header .block-main {
padding-left: 40px;
}
.zt-singular-header h4 {
font-size: 14px;
padding-bottom: 20px;
}
.zt-singular-header p {
font-size: 14px;
line-height: 2;
height: 4em;
margin-bottom: 30px;
overflow: hidden;
}
.zt-singular-header h4 .item {
padding: 0 20px;
}
.zt-singular-header h4 .item strong {
font-size: 32px;
}
.list-item-default .item-thumb {
width: 260px;
margin: 0 30px 0 0;
}
.list-item-default .title {
font-size: 20px;
font-weight: bold;
line-height: 30px;
margin-bottom: 20px;
}
.list-item-zt .zt-title {
display: block;
}
.list-item-default .title .tag {
padding: 1px 4px;
}
.list-item-zt .zt-title .item {
display: inline;
}
.list-item-zt .zt-title .item:last-child {
margin: 0;
}
.list-item-default p {
display: block;
}
}
@media (min-width: 1024px){
.list-item-default {
margin-bottom: 15px;
margin-left: -20px;
margin-right: -20px;
padding: 20px;
background: #fff;
transition: all .2s;
}
.zt-singular-header .container {
padding-top: 97px;
}
}
/*zhuanti end */
声明:
芒果源码,一个精品商业网站源码分享平台 WWW.OKMG.CN
请务必线上支付,通过线下支付的出现任何问题平台均不担保! 1. 本站所有资源来源于用户上传和网络,均不允许转载,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 如发现会员恶意下载,传播,或用于违法用途,本站有权封禁账号,并积极配合有关部门调查
4. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
5. 本站提供的源码、模板、插件等等其他资源(除商业源码分类),都不包含技术服务请大家谅解!
6. 如有链接无法下载、失效或广告,请联系管理员处理!
7. 本站资源售价和会员费只是赞助,收取费用仅维持本站的日常运营所需!
8. 如遇到加密压缩包,默认解压密码为"www.okmg.cn",如遇到无法解压的请联系管理员!
9.本站客服QQ:29139260
10.如您发现本站分享的源码,侵犯了您的权益,请联系:29139260#qq.com #换成@
芒果源码,一个精品商业网站源码分享平台 WWW.OKMG.CN
请务必线上支付,通过线下支付的出现任何问题平台均不担保! 1. 本站所有资源来源于用户上传和网络,均不允许转载,如有侵权请邮件联系站长!
2. 分享目的仅供大家学习和交流,您必须在下载后24小时内删除!
3. 如发现会员恶意下载,传播,或用于违法用途,本站有权封禁账号,并积极配合有关部门调查
4. 不得使用于非法商业用途,不得违反国家法律。否则后果自负!
5. 本站提供的源码、模板、插件等等其他资源(除商业源码分类),都不包含技术服务请大家谅解!
6. 如有链接无法下载、失效或广告,请联系管理员处理!
7. 本站资源售价和会员费只是赞助,收取费用仅维持本站的日常运营所需!
8. 如遇到加密压缩包,默认解压密码为"www.okmg.cn",如遇到无法解压的请联系管理员!
9.本站客服QQ:29139260
10.如您发现本站分享的源码,侵犯了您的权益,请联系:29139260#qq.com #换成@
智慧城市同城V4.0
上一篇
2020-07-08
lms教育行业官网模板下载
2020-07-08
下一篇
请务必线上支付,通过线下支付的出现任何问题平台均不担保!