以下列举黑白配博客从原生主题个性化的各种设置方法
零.知更鸟begin主题使用说明教程
这个不多说了,官方写的,但是官方加密了,这里转一个没加密的大佬博客转载的一个。
一.增加说说/微语单页
本教程来自络,首先在主题的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); }
然后新建一个shuoshuo.php文件放到你正在使用的主题根目录里把下面代码放入shuoshuo.php;
- <?php
- get_header(); ?>
- <style type="text/css">
- #shuoshuo_content {
- background-color: #fff;
- 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);
- }
- /* end */
- </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="《这里加入头像图片外链》" class="avatar avatar-48" width="48" height="48"></span>
- <a class="cbp_tmlabel" href="javascript:void(0)">
- <p></p>
- <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>
- <!-- .site-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>
- <?php get_sidebar(); ?>
- <?php get_footer();?>
然后在wordpress后台新建单页模板选择说说,头像在shuoshuo.php文件修改,大功告成,之后可通过后台发表说说了。
二.背景修改
<script type="text/javascript" src="https://cdn.bootcss.com/canvas-nest.js/1.0.1/canvas-nest.min.js"></script>
添加以上代码放至footer.php文件里面最后面的<?php wp_footer(); ?>前面,仅此,这是引用别人的,想要改脚本问度娘,有更具体的教程。
三.背景音乐
PoiPlayer插件即可,其实还有很多插件都可做背景音乐,不用写代码。。。。
PoiPlayer使用方法:言曌博客
四.导航图标
一、WP后台--插件--安装插件页面搜索:Font Awesome 4 Menus,下载安装并启用。
(注:博主使用的Begin主题用户,无需安装上述插件)
二、WP后台---外观---菜单,进入菜单设置页面,选择并编辑一个菜单项,在CSS类中输入一个图标字体选择器名称,如图:
如果在编辑菜单项目面板中无CSS类,可以打开右上角的“显示选项”,在显示菜单高级属性中勾选“CSS类”。
图标字体选择器名称,打开此页查看:http://fontawesome.io/icons/
点开一个认为合适的图标字体,在下会显示类似:
- <i class="fa fa-home"></i>
只需在菜单CSS类中输入fa fa-home就可以了。
当然这个图标字体库并不只局限于使用在导航菜单上,只要把相应的图标代码加到主题模板的相应位置,也同样可以显示。
如果认为上面插件提供的图标字体不符合自己的要求(其实这套Font Awesome图标字体早已烂大街),还可以自己做一套更加个性化的图标字体。
图标字体在线制作自行百度~
五.404页面
修改404.就直接更改主题的404模板,加入了腾讯公益的404脚本代码。
六.给网页底部添加蒲公英摇摆小动画
先给上本站白色的图片地址:http://www.z4a.net/images/2017/09/24/pgy5.png
现在网络上流传的多半是那个黄色的蒲公英,由于本人就喜欢搞个性化,自然改成了白色,hiahiahia。
你可以自己p张小logo在代码的url处改成你自己的外链或者相对路径地址
1.登陆你的后台管理,选择【外观】-【编辑】-【主题页脚 (footer.php)】
直接添加下面全部代码:
12 <!--飘动的蒲公英--><divclass="dandelion"><spanclass="smalldan"></span><spanclass="bigdan"></span></div>2.登陆你的后台管理,选择【外观】-【编辑】-【 样式表 (style.css)】
直接添加下面全部代码:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 /*飘动的蒲公英*/@mediascreenand (max-width:600px) {.dandelion {display: none!important;}}.dandelion .smalldan {left: 21px;width: 36px;height: 60px;border: 0 solidred;background-position: 0 -90px;}.dandelionspan {position: fixed;bottom: 0;z-index: 9999;display: block;background: 0 0;background-image: url(images/pgy.png);background-repeat: no-repeat;-webkit-transform-origin: bottomcenter;transform-origin: bottomcenter;-webkit-animation: ball-x 3s linear 2s infinite;animation: ball-x 3s linear 2s infinite;}.dandelion .bigdan {left: 47px;width: 4pc;height: 115px;border: 0 solidred;background-position: -86px -36px;}@keyframes ball-x {0% {transform: rotate(0);}20% {transform: rotate(5deg);}40% {transform: rotate(0);}60% {transform: rotate(-5deg);}80%,to {transform: rotate(0);}}@-webkit-keyframes ball-x {0% {-webkit-transform: rotate(0);}20% {-webkit-transform: rotate(5deg);}40% {-webkit-transform: rotate(0);}60% {-webkit-transform: rotate(-5deg);}80%,to {-webkit-transform: rotate(0);}}
七:正文底部添加”一句话“
直接放原文链接:https://xiaolin.in/read/hitokoto-api-xiaolin-edition.html。参考的大佬文章。
八:代码方式给博客添加smtp邮件功能
1.登陆QQ邮箱
2.选择左上角设置——账户——POP3/IMAP/SMTP/Exchange/CardDAV/CalDAV服务
3.开启POP3/SMTP服务与IMAP/SMTP服务
4.生成授权码
将下面代码中信息修改为自己信息,放进主题functions.php适当位置。
- //使用smtp发送邮件(请根据自己使用的邮箱设置SMTP)
- add_action('phpmailer_init', 'mail_smtp');
- function mail_smtp( $phpmailer ) {
- $phpmailer->FromName = '易趣博客'; //发件人名称
- $phpmailer->Host = 'smtp.qq.com'; //修改为你使用的邮箱SMTP服务器
- $phpmailer->Port = 465; //SMTP端口
- $phpmailer->Username = '123456@qq.com'; //邮箱账户
- $phpmailer->Password = '*****************'; //邮箱密码(此处填写QQ邮箱生成的授权码)
- $phpmailer->From = '123456@qq.com'; //邮箱账户
- $phpmailer->SMTPAuth = true;
- $phpmailer->SMTPSecure = 'ssl'; //tls or ssl (port=25时->留空,465时->ssl)
- $phpmailer->IsSMTP();
- }
根据注释将发件人名称、邮箱账户及邮箱密码修改为自己信息
5.其他的邮箱类似,不用过多赘述了
九:begin主题wp博客留言板页面模板设置代码,就调用评论功能
就简单的说一下:你可以去外观-编辑处看看comment.php的代码,复制一份然后修改一下换成留言板的。然后就是再建一个php文件调用,当作页面模板,调用代码如下
- <div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php while ( have_posts() ) : the_post(); ?>- <?php get_template_part('ad/ads', 'comments'); ?>
<?php if ( comments_open() || get_comments_number() ) : ?>
<?php comments_template( '/liuyan.php' ); ?>
<?php endif; ?>
<?php endwhile; ?>
</main><!-- .site-main -->
</div><!-- .content-area -->对于知更鸟主题的,你可以直接修改其他页面模板,在外观-编辑里面直接修改,然后调用,比如我改的是“最近读者”的模板。值得强调一下的是,虽然我不懂php,但是凭借c语言,英语和htm语言的功底,完全自己摸索出来了这个代码(因为可以查看其它页面然后推敲嘛),然后改了之后一直无法显示评论,居然是知更鸟主题在页面的快速编辑那里要把允许评论勾选,进去页面编辑反而没有这个选项,以前的版本可以在“讨论”选项里设置”允许评论“。反正就是这个关键点,搞的我怀疑人生,以为这个是多么个有技术含量的活...请教了一堆大佬(诗梦博客,杳无宗博客,,,还有问了没回我好像,忘了),反正在这里感谢他们~