【WP建站记录】zibll子比主题美化汇总(持续更新)

【WP建站记录】zibll子比主题美化汇总(持续更新)-绿野蓝衫

1.在主题 footer.php 文件中 标签前引用如下js文件即可

效果1:
<!--鼠标点击特效-->
<script type="text/javascript" src="https://你的资源地址/click.js"></script>

效果2:
<!--好看的鼠标点击爆炸效果 start-->
<script type="text/javascript" src="https://你的资源地址/meme.js"></script>

<canvas class="fireworks" style="position:fixed;left:0;top:0;z-index:99999999;pointer-events:none;"></canvas>

<script type="text/javascript" src="https://你的资源地址/anime.min.js"></script>

<script type="text/javascript" src="https://你的资源地址/fireworks.js"></script>
<!--好看的鼠标点击爆炸效果 END-->

【WP建站记录】zibll子比主题美化汇总(持续更新)-绿野蓝衫
【WP建站记录】zibll子比主题美化汇总(持续更新)-绿野蓝衫

在footer.php中添加如下代码

<!--网页标签动态标题效果-->
<script type="text/javascript" src="https://你的资源路径/title1.js"></script>

【WP建站记录】zibll子比主题美化汇总(持续更新)-绿野蓝衫

在主题文件下的footer.php文件中加入以下代码

<!--樱花飘落主题特效-->
<script src="https://你的资源路径/sakura-original.js"></script>

【WP建站记录】zibll子比主题美化汇总(持续更新)-绿野蓝衫

1.子比主题设置—>自定义代码—>自定义 CSS 样式:,添加以下 CSS 代码(代码中的图片地址可以修改,可以自己设计相关的素材图)

/*评论背景图*/
textarea#comment {background-color:transparent;background:linear-gradient(rgba(0, 0, 0, 0.05), rgba(0, 0, 0, 0.05)),url(https://imgsa.baidu.com/forum/pic/item/d439b6003af33a871f7e3f0e9b5c10385343b597.jpg) right 10px bottom 10px no-repeat;-moz-transition:ease-in-out 0.45s;-webkit-transition:ease-in-out 0.45s;-o-transition:ease-in-out 0.45s;-ms-transition:ease-in-out 0.45s;transition:ease-in-out 0.45s;}
textarea#comment:focus {background-position-y:789px;-moz-transition:ease-in-out 0.45s;-webkit-transition:ease-in-out 0.45s;-o-transition:ease-in-out 0.45s;-ms-transition:ease-in-out 0.45s;transition:ease-in-out 0.45s;}
/*评论背景图*/

【WP建站记录】zibll子比主题美化汇总(持续更新)-绿野蓝衫

自定义CSS样式中复制以下代码:

/*头像呼吸光环和鼠标悬停旋转放大开始*/
.avatar{border-radius: 50%; animation: light 4s ease-in-out infinite; transition: 0.5s;}.avatar:hover{transform: scale(1.15) rotate(720deg);}@keyframes light{0%{box-shadow: 0 0 4px #f00;} 25%{box-shadow: 0 0 16px #0f0;} 50%{box-shadow: 0 0 4px #00f;} 75%{box-shadow: 0 0 16px #0f0;} 100%{box-shadow: 0 0 4px #f00;}}
/*头像呼吸光环和鼠标悬停旋转放大结束*/

使用方法:

只需将下面的 PHP 代码加入到主题目录下:themes/zibll/functions.php 文件底部就可以了。

【WP建站记录】zibll子比主题美化汇总(持续更新)-绿野蓝衫

主题后台添加自定义CSS样式

/*手机侧边栏背景图片*/
@media (max-width: 767px){
.mobile-navbar.show,.mobile-navbar.left{
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center center;
    cursor: pointer;
  background-image:linear-gradient(rgba(255, 255,255,0),rgba(255,255,255, 0.3)),url(https://你的资源图片地址/1.jpg);}
  .mobile-nav-widget .box-body {
    background: var(--muted-border-color) !important;}
}
【WP建站记录】zibll子比主题美化汇总(持续更新)-绿野蓝衫

1、首先在子比主题目录的functions.php里面加入以下代码:

//微语
add_action('init', 'my_custom_init'); function my_custom_init() { $labels = array( 'name' => '微语', 'singular_name' => 'singularname', 'add_new' => '发表微语', 'add_new_item' => '发表微语', 'edit_item' => '编辑微语', 'new_item' => '新微语', 'view_item' => '查看微语', 'search_items' => '搜索微语', 'not_found' => '暂无微语', 'not_found_in_trash' => '没有已遗弃的微语', 'parent_item_colon' => '', 'menu_name' => '微语' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => true, 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => false, 'menu_position' => null, 'supports' => array('title','editor','author') ); register_post_type('shuoshuo',$args); }

2、然后在子比主题pages目录下新建一个weiyu.php文件,然后把下面代码放入weiyu.php文件中即可(注:代码中的nk=可以修改成自己的QQ号)

<?php

/**
 * Template name: 微语页面
 * Description:   weiyu
 */

// 获取链接列表
get_header();
$header_style = zib_get_page_header_style();
?>
<main class="container">
    <div class="content-wrap">
        <div class="content-layout">
            <?php while (have_posts()) : the_post(); ?>
                <?php if ($header_style != 1) {
                    echo zib_get_page_header();
                } ?>
                <?php endwhile;  ?>
                <div class="box-body theme-box radius8 main-bg main-shadow">
                    <?php if ($header_style == 1) {
                        echo zib_get_page_header();
                    } ?>
                <!--主体开始-->
                <style type="text/css">
                #shuoshuo_content{padding: 10px; /*min-height: 500px;*/} /* shuo */ body.theme-dark .cbp_tmtimeline::before{background: RGBA(255, 255, 255, 0.06);} ul.cbp_tmtimeline{padding: 0;} div class.cdp_tmlabel > li .cbp_tmlabel{margin-bottom: 0;} .cbp_tmtimeline{margin: 30px 0 0 0; padding: 0; list-style: none; position: relative;} /* The line */ .cbp_tmtimeline:before{/*content: '';*/ position: absolute; top: 0; bottom: 0; width: 4px; background: RGBA(0, 0, 0, 0.02); left: 80px; margin-left: 10px;} /* The date/time */ .cbp_tmtimeline > li .cbp_tmtime{display: block; /* width: 29%; */ /* padding-right: 110px; */ max-width: 70px; position: absolute;} .cbp_tmtimeline > li .cbp_tmtime span{display: block; text-align: right;} .cbp_tmtimeline > li .cbp_tmtime span:first-child{font-size: 0.9em; color: #bdd0db;} .cbp_tmtimeline > li .cbp_tmtime span:last-child{font-size: 1.2em; color: #9BCD9B;} .cbp_tmtimeline > li:nth-child(odd) .cbp_tmtime span:last-child{color: RGBA(255, 125, 73, 0.75);} div.cbp_tmlabel > p{margin-bottom: 0;} /* Right content */ .cbp_tmtimeline > li .cbp_tmlabel{margin: 0 0 45px 65px; background: #9BCD9B; color: #fff; padding: .8em 1.2em .4em 1.2em; /* font-size: 1.2em; */ font-weight: 300; line-height: 1.4; position: relative; border-radius: 5px; transition: all 0.3s ease 0s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15); cursor: pointer; display: block;} .cbp_tmlabel:hover{transform:scale(1.05); transform: translateY(-3px); z-index: 1; -webkit-box-shadow: 0 15px 32px rgba(0, 0, 0, 0.15) !important} .cbp_tmtimeline > li:nth-child(odd) .cbp_tmlabel{background: RGBA(255, 125, 73, 0.75);} /* The triangle */ .cbp_tmtimeline > li .cbp_tmlabel:after{right: 100%; border: solid transparent; content: " "; height: 0; width: 0; position: absolute; pointer-events: none; border-right-color: #9BCD9B; border-width: 10px; top: 4px;} .cbp_tmtimeline > li:nth-child(odd) .cbp_tmlabel:after{border-right-color: RGBA(255, 125, 73, 0.75);} p.shuoshuo_time{margin-top: 10px; border-top: 1px dashed #fff; padding-top: 5px;} /* Media */ @media screen and (max-width: 65.375em){.cbp_tmtimeline > li .cbp_tmtime span:last-child{font-size: 1.2em;} } .shuoshuo_author_img img{border: 1px solid #ddd; padding: 2px; float: left; border-radius: 64px; transition: all 1.0s;} .avatar{-webkit-border-radius: 100% !important; -moz-border-radius: 100% !important; box-shadow: inset 0 -1px 0 #3333sf; -webkit-box-shadow: inset 0 -1px 0 #3333sf; -webkit-transition: 0.4s; -webkit-transition: -webkit-transform 0.4s ease-out; transition: transform 0.4s ease-out; -moz-transition: -moz-transform 0.4s ease-out;} .zhuan{transform: rotateZ(720deg); -webkit-transform: rotateZ(720deg); -moz-transform: rotateZ(720deg);}
                </style>
                </head>
                <body>
                <div id="primary" class="content-area" style="">
                    <main id="main" class="site-main" role="main">
                        <div id="shuoshuo_content">
                            <ul class="cbp_tmtimeline">
                                <?php query_posts("post_type=shuoshuo&post_status=publish&posts_per_page=-1");if (have_posts()) : while (have_posts()) : the_post(); ?>
                                <li> <span class="shuoshuo_author_img"><img src="https://q1.qlogo.cn/g?b=qq&nk=1049649419&s=640" class="avatar avatar-48" style="width:48px;height:48px"></span>
                                    <a class="cbp_tmlabel" href="javascript:void(0)">
                                        <h4><?php the_title();   ?></h4>
                                        <p><?php the_content(); ?></p>
                                        <p></p>
                                        <p class="shuoshuo_time"><i class="fa fa-clock-o"></i>
                                            <?php the_time('Y年n月j日G:i'); ?>
                                        </p>
                                    </a>
                                    <?php endwhile;endif; ?>
                                </li>
                            </ul>
                        </div>
                    </main>
                </div>
                <script type="text/javascript">
                    $(function () {
                        var oldClass = "";
                        var Obj = "";
                        $(".cbp_tmtimeline li").hover(function () {
                            Obj = $(this).children(".shuoshuo_author_img");
                            Obj = Obj.children("img");
                            oldClass = Obj.attr("class");
                            var newClass = oldClass + " zhuan";
                            Obj.attr("class", newClass);
                        }, function () {
                            Obj.attr("class", oldClass);
                        })
                    })
                </script>
                <!--主体结束-->
                </div>
                <?php comments_template('/template/comments.php', true); ?>
        </div>
    </div>
    <?php get_sidebar(); ?>
</main>
<?php
get_footer();

3、最后在后台—>页面—>新建页面—>找到“页面属性”选择“微语页面”—>填写标题—>发布就可以啦!

4、发表微语只需在后台—>微语—>发表微语,然后发表自己喜欢的微语即可。

【WP建站记录】zibll子比主题美化汇总(持续更新)-绿野蓝衫

调用Layer.js,Layer.js是一个非常优秀的弹层组件,看自己是否已经调用了Layer组件(办法:先别调用下面的Layer.js,看直接使用第二步的代码能否使用,若无法使用就证明没有调用Layer,自己把下面的代码放到主题里【自定义头部HTML代码】)

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/layui/2.6.8/layui.min.js"></script>

jQuery代码,把下面的jQuery代码放到主题设置的【自定义javascript代码】就大功告成啦!

// 夜间切换
$(".toggle-theme").click(function() {
var toggleThemeText = "当前为日间模式";
if (!$("body").hasClass('dark-theme')) {
toggleThemeText = "当前为夜间模式";
}
layer.msg(toggleThemeText, {
time: 2000,
anim: 1
});
});

在写文章的时候,发布之前你会设置很多标签,比如模板,源码,等等,这些关键词,往往需要搜索才能找到,给大家分享这个是只要你的文章中包含了你网站的关键词,就会自动添加超链接,也是更好的协助网站收录优化,提高内页收录。

将下面的 PHP 代码加入到主题目录下:themes/zibll/functions.php 文件中。

// by 文章添加关键词链接开始
function wpkj_auto_add_tag_link($content){
$limit = 1; // 设置同一个标签添加几次链接
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
$link = get_tag_link($tag->term_id);
$keyword = $tag->name;
$cleankeyword = stripslashes($keyword);
$url = '<a target="_blank" href="'.$link.'" title="'.str_replace('%s', addcslashes($cleankeyword, '$'), __('View all posts in %s')).'">'.addcslashes($cleankeyword, '$').'</a>';
$regEx = '\'(?!((<.*?)|(<a.*?)))('. $cleankeyword . ')(?!(([^<>]*?)>)|([^>]*?</a>))\'s';
$content = preg_replace($regEx,$url,$content,$limit);
}
}
return $content;
}
add_filter( 'the_content', 'wpkj_auto_add_tag_link', 1 );  
// by 文章添加关键词链接结束

1 2 3 4

温馨提示:本文最后更新于2024-08-08 22:04:13,部分文章具有时效性,若有已失效,请在下方留言

感谢您的来访,获取更多精品内容请收藏本站。

© 版权声明
THE END
喜欢就投喂一下吧!
点赞12赞赏 分享
评论 共8条

请登录后发表评论