效果图:
教程:
第一步:
打开自己网站下的 /wp-content/themes/b2/funactions.php 文件,然后把下面的代码加入到文件内。
//获取评论数量 function zfunc_comments_users($postid=0,$which=0) { $comments = get_comments('status=approve&type=comment&post_id='.$postid); //获取文章的所有评论 if ($comments) { $i=0; $j=0; $commentusers=array(); foreach ($comments as $comment) { ++$i; if ($i==1) { $commentusers[] = $comment->comment_author_email; ++$j; } if ( !in_array($comment->comment_author_email, $commentusers) ) { $commentusers[] = $comment->comment_author_email; ++$j; } } $output = array($j,$i); $which = ($which == 0) ? 0 : 1; return $output[$which]; //返回评论人数 } return 0; //没有评论返回0 }; // 随机文章 function random_posts( $posts_num=5,$before='<li>',$after='</li>'){ global $wpdb; $sql = "SELECT ID, post_title,guid FROM $wpdb->posts WHERE post_status = 'publish' "; $sql .= "AND post_title != '' "; $sql .= "AND post_password ='' "; $sql .= "AND post_type = 'post' "; $sql .= "ORDER BY RAND() LIMIT 0 , $posts_num "; $randposts = $wpdb->get_results($sql); $output = ''; foreach ($randposts as $randpost) { $post_title = stripslashes($randpost->post_title); $permalink = get_permalink($randpost->ID); $output .= $before.'<a class="item-foot" href="' . $permalink . '" rel="bookmark" data-toggle="tooltip" data-original-title="随机文章:'; $output .= $post_title . '"><svg class="icon" aria-hidden="true"><use xlink:href="#iconlianjie"></use></svg><span id="wz">' . $post_title . '</span></a>'; $output .= $after; } echo '<div id="footgundong" class="wz"><ul>'.$output.'</ul></div>'; } //点赞统计 function dz($post_id){ global $wpdb; $sql = "SELECT SUM(`meta_value`) as num FROM `wp_postmeta` WHERE `meta_key`='like' AND `post_id`=$post_id"; $results = $wpdb->get_results($sql); echo $results[0]->num; }
第二步:
打开自己网站下的/wp-content/themes/b2/footer.php文件,在</footer>下面添加下方代码。 打开自己网站下的/wp内容/主题/b2/footer.php文件,在</fount>下面添加下方代码。
<!--底部导航--> <div class="footwaveline"> <i style="background-image: url(https://www.zym88.cn/wp-content/uploads/<a href="https://sjcnh.cn/tag/2022nian" target="_blank">2022</a>/03/2ba3e3376c27.png);display: inline-block;width: 210px;height: 120px;position: fixed;bottom: 0;z-index: 110;background-size: 100%;"></i> <div style="background: url(https://www.zym88.cn/wp-content/uploads/2022/03/cf3cdc8e21d1.png) 0 0 repeat-x;height: 3px;width: 100%;position: fixed;background-size: 10px 3px;z-index: 98;bottom: 40px;"></div> <div id="shi" style="position: fixed;bottom: 0;margin-left: 200px;z-index: 99;"> <h4 class="my-face" style="font-size:13px;margin:0 5px 2px 5px;color:#797979;margin-bottom: 10px;">夕阳无别事,等风也等你</h4> </div> <div style="width: 100%;height: 40px;position: fixed;bottom: 0;z-index: 97;box-shadow: 0 -2px 10px rgb(0 0 0 / 10%);background:#fff;"> <nav class="joe_header__below-logon" style="float: right;margin-right: 50px;"> <?php if (!is_single()) { echo random_posts()." <span class=\"wz-span\">随机推荐</span>"; } if(is_single()){ ?> <span style="margin-left:20px;"> <a href="javascript:(scrollTo('#comments',-100));" data-toggle="tooltip" data-original-title="评论"> <svg class="icon" aria-hidden="true"><use xlink:href="#iconpinglun"></use></svg><span style="color:var(--minor);">评论(<count><?php echo zfunc_comments_users($post->ID); ?></count>)</span> </a> </span> <span style="margin-left:20px;line-height: 45px;"> <a class="share-btn poster" poster-share="<?php the_ID();?>" title="分享海报" href="javascript:;"> <svg class="icon" aria-hidden="true"><use xlink:href="#iconfenxiang"></use></svg>分享 </a> </span> <?php } ?> <span style="margin-left:20px;line-height: 45px;"> <a href="javascript:void(0);" onclick="javascript:addshoucang()" data-toggle="tooltip" title="收藏本站"> <svg class="icon" aria-hidden="true"><use xlink:href="#iconshoucang"></use></svg>使用Ctrl+D收藏本站 </a> </span> <a href="javascript:(scrollTo('#comments',-100));" href="javascript:(scrollTo());" id="percentage" data-toggle="tooltip" data-original-title="返回顶部"> <svg class="icon" aria-hidden="true"><use xlink:href="#icondingwei"></use></svg>0% </a> </nav> </div> </div> <!--底部导航-->
图片资源是站长放在自己网站媒体库里的,你们把图片保存下来上传到自己网站媒体库即可。
第三步:
进入后台B2主题设置>常规设置,在底部HTML标签加入下方代码。
<!-- 引入VUE --> <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.min.js"></script> <!-- 引入样式 --> <script src="https://cdn.jsdelivr.net/npm/element-ui@2.15.6/lib/index.js"></script> <!-- 引入组件库 --> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/element-ui@2.15.6/packages/theme-chalk/lib/index.css"> <!--自用阿里巴巴图标库--> <script src="//at.alicdn.com/t/font_2232826_a0tvv0wxh9n.js"></script>
第四步:
自定义css样式加入下方代码。在style.css文件里
/* 底部导航 start */.my-face { animation: my-face 5s infinite ease-in-out; color: #00f1ff; display: inline-block; margin: 0 5px; } @-webkit-keyframes my-face { 2%, 24%, 80% { -webkit-transform: translate(0, 1.5px) rotate(1.5deg); transform: translate(0, 1.5px) rotate(1.5deg) } 4%, 68%, 98% { -webkit-transform: translate(0, -1.5px) rotate(-.5deg); transform: translate(0, -1.5px) rotate(-.5deg) } 38%, 6% { -webkit-transform: translate(0, 1.5px) rotate(-1.5deg); transform: translate(0, 1.5px) rotate(-1.5deg) } 8%, 86% { -webkit-transform: translate(0, -1.5px) rotate(-1.5deg); transform: translate(0, -1.5px) rotate(-1.5deg) } 10%, 72% { -webkit-transform: translate(0, 2.5px) rotate(1.5deg); transform: translate(0, 2.5px) rotate(1.5deg) } 12%, 64%, 78%, 96% { -webkit-transform: translate(0, -.5px) rotate(1.5deg); transform: translate(0, -.5px) rotate(1.5deg) } 14%, 54% { -webkit-transform: translate(0, -1.5px) rotate(1.5deg); transform: translate(0, -1.5px) rotate(1.5deg) } 16% { -webkit-transform: translate(0, -.5px) rotate(-1.5deg); transform: translate(0, -.5px) rotate(-1.5deg) } 18%, 22% { -webkit-transform: translate(0, .5px) rotate(-1.5deg); transform: translate(0, .5px) rotate(-1.5deg) } 20%, 36%, 46% { -webkit-transform: translate(0, -1.5px) rotate(2.5deg); transform: translate(0, -1.5px) rotate(2.5deg) } 26%, 50% { -webkit-transform: translate(0, .5px) rotate(.5deg); transform: translate(0, .5px) rotate(.5deg) } 28% { -webkit-transform: translate(0, .5px) rotate(1.5deg); transform: translate(0, .5px) rotate(1.5deg) } 30%, 40%, 62%, 76%, 88% { -webkit-transform: translate(0, -.5px) rotate(2.5deg); transform: translate(0, -.5px) rotate(2.5deg) } 32%, 34%, 66% { -webkit-transform: translate(0, 1.5px) rotate(-.5deg); transform: translate(0, 1.5px) rotate(-.5deg) } 42% { -webkit-transform: translate(0, 2.5px) rotate(-1.5deg); transform: translate(0, 2.5px) rotate(-1.5deg) } 44%, 70% { -webkit-transform: translate(0, 1.5px) rotate(.5deg); transform: translate(0, 1.5px) rotate(.5deg) } 48%, 74%, 82% { -webkit-transform: translate(0, -.5px) rotate(.5deg); transform: translate(0, -.5px) rotate(.5deg) } 52%, 56%, 60% { -webkit-transform: translate(0, 2.5px) rotate(2.5deg); transform: translate(0, 2.5px) rotate(2.5deg) } 58% { -webkit-transform: translate(0, .5px) rotate(2.5deg); transform: translate(0, .5px) rotate(2.5deg) } 84% { -webkit-transform: translate(0, 1.5px) rotate(2.5deg); transform: translate(0, 1.5px) rotate(2.5deg) } 90% { -webkit-transform: translate(0, 2.5px) rotate(-.5deg); transform: translate(0, 2.5px) rotate(-.5deg) } 92% { -webkit-transform: translate(0, .5px) rotate(-.5deg); transform: translate(0, .5px) rotate(-.5deg) } 94% { -webkit-transform: translate(0, 2.5px) rotate(.5deg); transform: translate(0, 2.5px) rotate(.5deg) } 0%, 100% { -webkit-transform: translate(0, 0) rotate(0); transform: translate(0, 0) rotate(0) } } @keyframes my-face { 2%, 24%, 80% { -webkit-transform: translate(0, 1.5px) rotate(1.5deg); transform: translate(0, 1.5px) rotate(1.5deg) } 4%, 68%, 98% { -webkit-transform: translate(0, -1.5px) rotate(-.5deg); transform: translate(0, -1.5px) rotate(-.5deg) } 38%, 6% { -webkit-transform: translate(0, 1.5px) rotate(-1.5deg); transform: translate(0, 1.5px) rotate(-1.5deg) } 8%, 86% { -webkit-transform: translate(0, -1.5px) rotate(-1.5deg); transform: translate(0, -1.5px) rotate(-1.5deg) } 10%, 72% { -webkit-transform: translate(0, 2.5px) rotate(1.5deg); transform: translate(0, 2.5px) rotate(1.5deg) } 12%, 64%, 78%, 96% { -webkit-transform: translate(0, -.5px) rotate(1.5deg); transform: translate(0, -.5px) rotate(1.5deg) } 14%, 54% { -webkit-transform: translate(0, -1.5px) rotate(1.5deg); transform: translate(0, -1.5px) rotate(1.5deg) } 16% { -webkit-transform: translate(0, -.5px) rotate(-1.5deg); transform: translate(0, -.5px) rotate(-1.5deg) } 18%, 22% { -webkit-transform: translate(0, .5px) rotate(-1.5deg); transform: translate(0, .5px) rotate(-1.5deg) } 20%, 36%, 46% { -webkit-transform: translate(0, -1.5px) rotate(2.5deg); transform: translate(0, -1.5px) rotate(2.5deg) } 26%, 50% { -webkit-transform: translate(0, .5px) rotate(.5deg); transform: translate(0, -1.5px) rotate(2.5deg) } 26%, 50% { -webkit-transform: translate(0, .5px) rotate(.5deg); transform: translate(0, .5px) rotate(.5deg) } 28% { -webkit-transform: translate(0, .5px) rotate(1.5deg); transform: translate(0, .5px) rotate(1.5deg) } 30%, 40%, 62%, 76%, 88% { -webkit-transform: translate(0, -.5px) rotate(2.5deg); transform: translate(0, -.5px) rotate(2.5deg) } 32%, 34%, 66% { -webkit-transform: translate(0, 1.5px) rotate(-.5deg); transform: translate(0, 1.5px) rotate(-.5deg) } 42% { -webkit-transform: translate(0, 2.5px) rotate(-1.5deg); transform: translate(0, 2.5px) rotate(-1.5deg) } 44%, 70% { -webkit-transform: translate(0, 1.5px) rotate(.5deg); transform: translate(0, 1.5px) rotate(.5deg) } 48%, 74%, 82% { -webkit-transform: translate(0, -.5px) rotate(.5deg); transform: translate(0, -.5px) rotate(.5deg) } 52%, 56%, 60% { -webkit-transform: translate(0, 2.5px) rotate(2.5deg); transform: translate(0, 2.5px) rotate(2.5deg) } 58% { -webkit-transform: translate(0, .5px) rotate(2.5deg); transform: translate(0, .5px) rotate(2.5deg) } 84% { -webkit-transform: translate(0, 1.5px) rotate(2.5deg); transform: translate(0, 1.5px) rotate(2.5deg) } 90% { -webkit-transform: translate(0, 2.5px) rotate(-.5deg); transform: translate(0, 2.5px) rotate(-.5deg) } 92% { -webkit-transform: translate(0, .5px) rotate(-.5deg); transform: translate(0, .5px) rotate(-.5deg) } 94% { -webkit-transform: translate(0, 2.5px) rotate(.5deg); transform: translate(0, 2.5px) rotate(.5deg) } 0%, 100% { -webkit-transform: translate(0, 0) rotate(0); transform: translate(0, 0) rotate(0) } } /* end */@media (max-width: 800px){.footwaveline{display: none; #footgundong{margin-left:20px;overflow: overlay;display: inline-flex;text-align: right;} .item-foot{color: var(--minor);height: 45px;line-height: 45px;transition: color 0.35s;white-space: nowrap;} .swal-footer{text-align:center;} .swal-button {font-size: 20px;} .count>svg,.count>text{display:none;} .wz-span { border: 1px solid #bbbbbb; height: auto; color: #bbbbbb; font-size: 10px; border-radius: 2px; padding: 0 2px; } /*底部导航*/
第五步:
在child.js 加入下方代码。